GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 22-Sep-2008, 18:51
arjunu arjunu is offline
New Member
 
Join Date: Sep 2008
Posts: 1
arjunu is on a distinguished road

The Ballarat Airline Company (BAC) wants a simple program


Please send me the code at arjun.upadhya@yahoo.com

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 C++, and create auxiliary C++ 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. classes Stack<T> and List<T> [4 marks each]. Create class templates Stack<T> and List<T>. You may need to make appropriate changes to the classes Stack and List discussed in the lectures. Class Stack<T> should contain a function with the following prototype

friend ostream& operator<<(ostream& stream, Stack<T*> &c);

that prints contents of the stack.

3. Class City [4 marks]. Create a class City, which has the following private instance variables:

• string name; // name of the city
• List<City*> *nextCities; // A pointer to a List of the cities to which there is a flight from the city.
• bool visited; // the variable that shows whether the city has already been visited during the request processing algorithm.

The class also should contain constructor(s) and get and set functions for the instance variables.
There also should be a public function City* getNextUnvisitedCity() that returns a pointer to some “unvisited” city from the nextCities list, if there is any, otherwise returns NULL.

4. A function with the header
function Stack<City>* isPath(City * originCity, City * destinationCity)
that implements the Main Algorithm described in section 1.
[5 marks]
5. main function, 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). [3 marks]
  #2  
Old 22-Sep-2008, 19:10
ocicat ocicat is offline
Regular Member
 
Join Date: May 2008
Posts: 586
ocicat is a jewel in the roughocicat is a jewel in the rough

Re: I want coding for this assignment - Please help


Quote:
Originally Posted by arjunu
Please send me the code at arjun.upadhya@yahoo.com
Although there are unscrupulous sites where you can go & demand someone to write code for you, this is not one of them. If you want to put forth effort & understand how to do the work yourself, you are welcomed to stay & discuss. Otherwise, your expectations & what we attempt to achieve here are two vastly different goals.
  #3  
Old 22-Sep-2008, 20:08
dlp dlp is offline
Member
 
Join Date: May 2006
Posts: 157
dlp has a spectacular aura about

Re: I want coding for this assignment - Please help


I want one million dollars. Please send to:

Do Your Own Homework
On Your Own Time Blvd
Don't Be Lazy, Do It Yourself
USA

KTHXBYE.
  #4  
Old 22-Sep-2008, 20:51
L7Sqr L7Sqr is offline
Member
 
Join Date: Jul 2005
Location: constant limbo
Posts: 234
L7Sqr is a jewel in the roughL7Sqr is a jewel in the rough

Re: I want coding for this assignment - Please help


What you have copied here is an almost exact blueprint for what you need to do. It is so much so that it is starting to resemble pseudocode.
Lets take an example from your post:
Quote:
I We create an empty stack;
The first google hit gives me a link to how to do this (google: c++ stack)
CPP / C++ / C Code:
stack<int> stk;
stk.push(42);
stk.pop ();
And then we look at
Quote:
II All cities are marked as “unvisited”;
Which means you are going to need a way to associate a city with a boolean 'visited' flag. You could do this the proper way and wrap it in a class, but you could also use the quick 'n dirty pair
CPP / C++ / C Code:
pair<int,bool> visited;
visited.first = 42;
visited.second = false;
Moving right along...
Quote:
III We mark city X as “visited” and push it onto the stack;
The nice thing about the standard library containers is that they work with any data type, so now that you need to push and pop these associations, you can simply do
CPP / C++ / C Code:
stack<pair<int,bool> > stk;
stk.push(pair<int,bool>(42,false));

You get the idea. Its not every day that you get such a detailed description of how to do an assignment. I would suggest you take this and get as much out if it as you can. Things will only get more vague from here on in. Usually you will get an assignment that will reflect the following:
Quote:
The Ballarat Airline Company (BAC) wants a simple program to process customer requests to fly from some origin city to some destination city. Make sure you consider all possibilities (no destination, alternate routes, etc)
__________________
My personal site: Utilities for text processing, debugging, testing and plotting
 
 

Recent GIDBlogProblems with the Navy (Enlisted) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Assignment Operator and Pointer Peter_APIIT C++ Forum 14 25-Sep-2007 05:36
double concatenated dynamic list - different type assignment warning dlp C Programming Language 11 01-Jun-2007 07:59
Thread synchronization Assignment help!! rossi143 C Programming Language 1 25-Mar-2007 20:10
Am I reading this assignment correctly? earachefl C++ Forum 2 09-May-2006 09:39
C Coding Style dsmith Miscellaneous Programming Forum 10 24-Feb-2004 06:23

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 02:15.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.