plz help me by solving this problm


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: plz help me by solving this problm

Threaded View

  1. #1
    Join Date
    May 2006
    Posts
    2

    plz help me by solving this problm

    i got this assignment ,plz help me by solving this problm.the problem is like this. i have attached the problem as word document.

    0. Introduction. The Ballarat Airline Company (BAC) wants a simple program to process customer requests to fly from some origin city to some destination city: For each customer request, the program has to indicate whether a sequence of BAC flights exists from the origin city to the destination city, and, if such a sequence exists, the program prints it.
    The following figure represents the routs that BAC flies (for simplicity cities on the figure are denoted by C1, C2, …, C9):




    Notice that not all BAC flights have return flights, for example there is a BAC flight from C1 to C2, but not a BAC flight from C2 to C1.

    The algorithm for processing customer requests is described in the following section and uses stacks. You must “translate” the algorithm into Java, and create auxiliary Java classes as specified below.
    1. The Main Algorithm. Let us assume that we have a request to find a sequence of flights from X to Y. The request must be processed in the following way:

    I We create an empty stack;
    II All cities are marked as “unvisited”;
    III We mark city X as “visited” and push it onto the stack;
    IV While the stack is not empty and top city in the stack is not the destination city Y:
    • If there is some “unvisited” city adjacent to the top city, we mark it as “visited” and push it onto the stack
    • Else we pop the stack
    IV Return the stack. If the stack is not empty it contains the sequence of flights from X to Y. If the stack is empty, such sequence does not exist.


    2. Generic classes Stack<T> and List<T >.
    Create generic classes Stack<T> and List<T>. You need to make necessary changes to the classes Stack and List discussed in the lectures. Class Stack<T> must contain a method that prints contents of the stack.

    3. Class City :Create a class City, which has the following instance variables:

    • private String name; // name of the city
    • private List<City> nextCities; // List of cities to which there is a flight from this
    • private boolean visited; // the variable that shows whether the city has been //already visited during the request processing algorithm.

    The class also must contain constructor(s) and get and set methods for the instance variables.
    There also must be a method “public City getNextUnvisitedCity()” which returns some “unvisited” city from the nextCities list, if there is any, otherwise returns null.

    4. Class RequestProcessor. This class has one instance variable: “private List<City> cities” – which refers to the list of City objects in the flight map;
    A constructor that receives a parameter of List<City> type to initialize the instance variable;
    And two methods:

    • “public Stack<City> isPath(City originCity, City destinationCity)” – method implements the Main Algorithm described in section 1.
    • main method, in which you create 9 cities according to the information given in the flight map (figure in section 0) and then process customer requests for three different pairs of cities (you can choose the pairs yourself).

    Thanks In advance.
    Attached Files Attached Files
    Last edited by sukumardas; 05-25-2006 at 07:48 AM.

Similar Threads

  1. Replies: 8
    Last Post: 02-09-2006, 10:03 PM
  2. plz help me n00b here
    By Apocalyp5e in forum Java
    Replies: 11
    Last Post: 12-22-2005, 08:03 PM
  3. plz plz plz help me(java)
    By kamon in forum Java
    Replies: 4
    Last Post: 08-10-2005, 10:30 AM
  4. java applet... i'm in a fix, plz help
    By nsbscool in forum Java
    Replies: 1
    Last Post: 05-02-2005, 08:01 AM
  5. Plz Help!!!!
    By Kyle in forum Java
    Replies: 0
    Last Post: 05-14-2003, 03:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center