Prepare an implementation of the citypathconnector interface

Assignment Help Computer Engineering
Reference no: EM131984742

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.

Reference no: EM131984742

Questions Cloud

Value of the bond if interest rates unexpectedly increased : Calculate the value of the bond. Calculate the value of the bond if interest rates unexpectedly increased by 1%.
Describe what buffett means by float : Describe what Buffett means by "float" and "underwriting profit" in his overview of Berkshire's insurance business.
Construct a histogram showing percent frequency distribution : HI6007 Group Assignment - Construct a histogram showing the percent frequency distribution of the furniture-order values in the sample
How much will you pay for the policy : Calculating Perpetuity Values. Curly's Life Insurance Co. is trying to sell you an investment that will pay you and your heirs $25,000 per year forever.
Prepare an implementation of the citypathconnector interface : Prepare an implementation of the CityPathConnector interface. Use the ListCitySelector. This allows you to hard code a city order so you can test specific test.
Returns level stream of four annual payments : Consider an investment scenario that returns a level stream of four annual payments of $10,000 each (i.e., an annuity).
What is present value of the investment : What is the present value of the investment at a discount rate of 8%?
Why does chekov subtitle this play a comedy in four acts : With all that in mind, why does Chekov subtitle this play A Comedy in Four Acts?
How much will you have at the end of ten years : In Year 1, you plan to deposit $3000. In year 2 and Year 3, you plan to deposit $4000 and in Year 4 and 5, you plan to deposit $5000.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Work out the matrix dimension n automatically

Write down a C++ program that uses class Matrix for dealing with the square matrices (n x n tables of integers). The class constructor has to create a dynamic nxn matrix for n passed as a parameter.

  More detail to be shown as a process is exploded

In data flow diagrams (DFDs), a process symbol can be referred to as a black box, becase the inputs, outputs, and general funcions of the process are known, but the underlying details and logic of the system are hidden.

  Questionyou are working on a project to increase an

questionyou are working on a project to increase an intranet and several people are confused about who requests to do

  Global economy

Explain why is the global economy so vital today? Explain how the global economy has altered since the mid-twentieth century.

  What exception would be thrown if arithmetic were performed

What type of exception would be thrown if the following arithmetic were performed? double aValue = 0, bValue = 0; int result = (int) aValue / (int) bValue;

  Design class to focus on particular aspect data collection

Design and implement a set of classes that keeps track of demographic information about a set of people, such as age, nationality, occupation, income.

  Calculate how many weeks it would take for the weight

Using a while loop, calculate how many weeks it would take for the weight of the first rat to become 25 percent heavier than it was originally.

  How many published pages of text would fit on a netbook

a typical published page consists of approximately forty lines at seventy-five characters per line.a. how many

  Compute the number of flops required to set up the matrix p

For n- [5 10 20 40] and for each of the two methods mentioned in §5.1.1, compute the number of flops required to set up the matrix P.

  Write a java class that extends the progression class

Write a Java class that extends the Progression class so that each value in the progression is the absolute value of difference between the previous two values.

  Discuss how you think it applies to homeland security

After reading the Robert Frost poem please respond as to how you think it applies to Homeland Security. Do fences make good neighbors

  Write a function called minimum that return smallest integer

Write a function called Minimum that returns the smallest of its three Integer parameters.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd