Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Assignment

This lab is about finding a path from some source city to a destination city. Cities are represented by the City enum in the provided jar file. CitySelector is a provided interface that determines a "next hop" city (the next city to go to). CityPathConnector is a provided interface that uses a CitySelector to determine a path from a given source city to a given destination city.

Starting from the source city, a CityPathConnector will get the next city to visit from its CitySelector. The CityPathConnector will repeatedly do this until the CitySelector presents the destination city, at which point the path is complete. The CityPathConnector needs to keep track of which intermediary cities were visited.

For example, a path from New York to Atlanta might be:

New York, Washington, Boston, Los Angeles, Atlanta

Note that the realistic practicality of the path is not a concern for this lab.

However, here's a caveat. The CitySelector may return null; this denotes that there are no paths from the current city. When this happens, the CityPathConnector needs to go back to the previously visited city.

For example, given a source of New York and destination of Atlanta, the first part of the path might be:

New York, Washington, Boston

If the next city to visit is null, then the path becomes

New York, Washington, Boston, Washington

And the CityPathConnector checks for a next city from Washington (a CitySelector will not present a city more than once).

From there, the path can be completed; for example:

New York, Washington, Boston, Washington, Charlotte, Atlanta

Or, it will be possible that the CitySelector will return a string of null values, denoting that there is no path to the destination; for example:

New York, Washington, Boston, Washington, New York (null value and done).

Values of null presented by the CitySelector denote dead-end cities. When this happens on a path, we will also want to know what the "direct" (for lack of a better term) path is. For example, if the full path is:

New York, Washington, Boston, Washington, Charlotte, Atlanta

Then the direct path is:

New York, Washington, Charlotte, Atlanta

And when there is no path to the destination, the direct path will be empty. For example (going from New York to Atlanta):

Full Path: New York, Washington, Boston, Washington, New York Direct Path: (empty)

Part 1

1. Create an implementation of the CityPathConnector interface.

a. Use the stack data structure (java.lang.Stack) in your implementation.

Part 2

There are three ways to test and validate your implementation, as follows.

1. Use the RandomCitySelector which will present cities or null values in random order. A null value has equal chance as any eligible city to be presented.

2. Use the ListCitySelector. This allows you to hard code a city order so you can test specific test cases.

3. Use CityPathConnectorTester. This will automatically run your CityPathConnector against a series of predefined test cases and will show you which test cases were failed, if any.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92822395

Have any Question?


Related Questions in Computer Engineering

Can you help to identify a firm with which an organization

Can you help to identify a firm with which an organization does business and can you help explain if the firm is: perfectly competitive; monopolistic competitive; oligopoly; or pure monopoly?

A 2500ml sample of sulfuric acid a diprotic acid was

A 25.00mL sample of sulfuric acid, a diprotic acid, was titratedwith 24.66mL of aqueous NaOH. Upon evaporation, 0.550g of drysodium sulfate was recovered. a. What is the normality of the sulfuric acid b. What this the no ...

Should we be renegotiating nafta yes or no if it is

Should we be renegotiating NAFTA? yes or no? If it is renegotiated, should it be replaced? What reasons would make it better in your point of view? What is the best argument you can make why NAFTA should or should not be ...

The equation of regression line for sons heighty in inches

The equation of regression line for son's height(y) in inches versus father's height in inches is y = 35 + 0.5x. For a 72 inch tall father, what would we predict for the son's height?

A string in c is simply an array of characters with the

A string in C++ is simply an array of characters with the null character(\0) used to mark the end of the string. C++ provides a set of string handling function in as well as I/O functions in . With the addition of the ST ...

Qestion what steps are involved for implementing sw s0 0

Question : What steps are involved for implementing sw $s0 , 0 ( $s1) instruction . Draw data path and control path for this instruction. The response must be typed, single spaced, must be in times new roman font (size 1 ...

A string in c is simply an array of characters with the

A string in C++ is simply an array of characters with the null character(\0) used to mark the end of the string. C++ provides a set of string handling function in as well as I/O functions in . With the addition of the ST ...

Question two paragraphs eachseparate responds1 uml and omg

Question: TWO PARAGRAPHS EACH SEPARATE RESPONDS 1. "UML and OMG" Please respond to the following: Identify the benefits that UML brings to the software development industry. Speculate UML's development and its future inf ...

Not all context free grammars define regular languages

Not all context free grammars define regular languages. However, the following two DO define regular languages. For each grammar below, (a) describe the corresponding language and (b) draw the corresponding finite state ...

30 of the cars in a dealer lot are red 21 are black and 22

30% of the cars in a dealer lot are red, 21% are black, and 22% are white. The remainder are some other unspecified color. Salespersons randomly shows three cars to three different customers. What is the probability the ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As