QuestionCan you help me design the interface console for my assignment ...
Can you help me design the interface console for my assignment
Additional Notes:
- You cannot add two flights with the same flight number
- When you select "View Flights", a list containing the Flight number, origin and destination for each flight must be shown.
- When you select "View a particular flight", a list of all flights should be displayed and the user must be allowed to enter a particular flight number. All the information on that selected flight must be displayed. All the customers who are booked on that flight must
SPECIAL NOTE:
A customer can only be deleted if there are no bookings for that customer.
A flight can only be deleted if there are no customers booked on the flight.
You must extend the core design and add the functionality to add customers and booking features to the system.
The information that must be recorded on a customer is as follows:
- A customer ID must be assigned to each customer by the system. (NOT entered by the user)
- The customer's first name
- The customer's last name.
- The customer's phone (a string type is fine for this)
- The number of bookings the customer has made
Your main menu should have the new options:
- Make booking
- View bookings
ADD CUSTOMER
When the "Add Customer" option is selected, all information necessary to make the customer object must be asked for.
A customer can only be added if there is no other customer with the same first name, last name and phone number (all three cannot be the same). An appropriate message as to whether the customer addition was successful or not should be displayed.
VIEW CUSTOMERS
When "View Customers" is selected, the first name, last name and phone number must be displayed for each customer.
The information that must be recorded on a booking is as follows:
- The date of the booking ( a string)
- A booking number must be assigned by the system. (NOT entered by the user)
- The flight object the booking is being made for.
- The customer object the booking is being made for
Note : you can use the following code to get the date and time from your system as a string...
string date = DateTime.Now.ToString(@"MM/dd/yyyy h:mm tt");
Your main menu should have the new options:
- Make booking
- View bookings
MAKE BOOKINGS
When the "Add booking" option is selected, a list of all customers and all flights should be displayed first. The user must then be asked for the Customer id and flight id to make the booking for.
A booking can only be made if there is free space on the plane, the customer id exists and the flight id exists. All associated objects should be updated. An appropriate message as to whether the booking was successful or not should be displayed.
VIEW BOOKINGS
When "View bookings" is selected, the date, booking number, customer name and flight number must be displayed for each booking.
Your main class/program (the default one created when you make a new project) will be responsible for creating an AirlineCoordinator object as well as the complete menu system
Ensure that the interface/s generated by your program is user-friendly and gives a professional look.
Image transcription text
XYZ Airlines Limited. Customer Menu Please select a choice from the menu below: 1: Add Customer 2: View
Customers 3: Delete Customer Back to main menu XYZ AirLines Limited. Flight Menu XYZ Airlines Limited.
Please select a choice from the menu below: Please select a choice from the menu below: 1: Add...
Show more
Starting code:
FLIGHT CLASS
classFlight
{
privateint flightNumber;
privatestring origin;
privatestring destination;
privateint maxSeats;
privateint numPassengers;
private Customer[] passengers;
public Flight(int fn,string or,string dest,int mSeats)
{
maxSeats = mSeats;
flightNumber = fn;
origin = or;
destination = dest;
numPassengers = 0;
passengers =new Customer[maxSeats];
}
publicint getFlightNumber() {return flightNumber; }
publicstring getOrigin() {return origin; }
publicstring getDestination() {return destination; }
publicint getMaxSeats() {return maxSeats; }
publicint getNumPassengers() {return numPassengers; }
publicbool addPassenger(Customer c)
{
if (numPassengers >= maxSeats) {returnfalse; }
passengers[numPassengers] = c;
numPassengers++;
returntrue;
}
publicint findPassenger(int custId)
{
for (int x = 0; x
{
if (passengers[x].getId() == custId)
return x;
}
return -1;
}
publicbool removePassenger(int custId)
{
int loc = findPassenger(custId);
if (loc == -1)returnfalse;
passengers[loc] = passengers[numPassengers - 1];
numPassengers--;
returntrue;
}
publicstring getPassengerList()
{
string s ="nPassengers on flight " + flightNumber +":";
for (int x = 0; x
{
s = s +"n" + passengers[x].getFirstName() +" " + passengers[x].getLastName();
}
return s;
}
publicstring toString()
{
string s ="Flight Number: " + flightNumber;
s = s +"nOrigin: " + origin;
s = s +"nDestination:" + destination;
s = s +"nNumber of Passengers:" + numPassengers;
s = s +"nAvailable seats:" + (maxSeats - numPassengers);
s = s + getPassengerList();
return s;
}
}
FLIGHT MANAGER CLASS
classFlightManager
{
privateint maxFlights;
privateint numFlights;
private Flight[] flightList;
public FlightManager(int max)
{
maxFlights = max;
numFlights = 0;
flightList =new Flight[maxFlights];
}
publicbool addFlight(int fn,string origin,string destination,int maxSeats)
{
if (numFlights >= maxFlights) {returnfalse; }
Flight f =new Flight(fn, origin,destination,maxSeats);
flightList[numFlights] = f;
numFlights++;
returntrue;
}
publicint findFlight(int fid)
{
for (int x = 0; x
{
if (flightList[x].getFlightNumber() == fid)
return x;
}
return -1;
}
publicbool flightExists(int fid)
{
int loc = findFlight(fid);
if (loc == -1) {returnfalse; }
returntrue;
}
public Flight getFlight(int fid)
{
int loc = findFlight(fid);
if (loc == -1) {returnnull; }
return flightList[loc];
}
publicbool deleteFlight(int fid)
{
int loc = findFlight(fid);
if (loc == -1) {returnfalse; }
flightList[loc] = flightList[numFlights-1];
numFlights--;
returntrue;
}
publicstring getFlightList()
{
string s ="Flight List:";
for (int x = 0; x
{
s = s +"n" + flightList[x].getFlightNumber() +" from " + flightList[x].getOrigin() +" to " + flightList[x].getDestination();
}
return s;
}
}
CUSTOMER CLASS
classCustomer
{
privateint customerId;
privatestring firstName;
privatestring lastName;
privatestring phone;
privateint bookings;
public Customer(int cId,string fname,string lname,string ph)
{
bookings = 0;
customerId = cId;
firstName = fname;
lastName = lname;
phone = ph;
}
publicint getId() {return customerId; }
publicstring getFirstName() {return firstName; }
publicstring getLastName() {return lastName; }
publicstring getPhone() {return phone; }
publicint getNumBookings() {return bookings; }
publicstring toString()
{
string s ="Customer "+customerId;
s = s +"nName: "+firstName+" "+lastName;
s = s +"nPhone: "+phone;
s = s +"n Bookings: " + bookings;
return s;
}
}
AIRLINE COORDINATOR CLASS
classAirlineCoordinator
{
FlightManager flManager;
CustomerManager custManager;
public AirlineCoordinator(int custIdSeed,int maxCust,int maxFlights)
{
flManager =new FlightManager(maxFlights);
}
publicbool addFlight(int flightNo,string origin,string destination,int maxSeats)
{
return flManager.addFlight(flightNo, origin, destination, maxSeats);
}
publicstring flightList()
{
return flManager.getFlightList();
}
publicbool deleteFlight(int fid)
{
return flManager.deleteFlight(fid);
}
}
MAIN PROGRAM
classProgram
{
static AirlineCoordinator aCoord;
publicstaticvoid deleteFlight()
{
int id;
Console.Clear();
Console.WriteLine(aCoord.flightList());
Console.Write("Please enter a flight id to delete:");
id = Convert.ToInt32(Console.ReadLine());
if (aCoord.deleteFlight(id))
{
Console.WriteLine("Flight with id {0} deleted..", id);
}
else
{
Console.WriteLine("Flight with id {0} was not found..", id);
}
Console.WriteLine("nPress any key to continue return to the main menu.");
Console.ReadKey();
}
publicstaticvoid viewFlights()
{
Console.Clear();
Console.WriteLine(aCoord.flightList());
Console.WriteLine("nPress any key to continue return to the main menu.");
Console.ReadKey();
}
publicstaticvoid addFlight(){
int flightNo,maxSeats;
string origin, destination;
Console.Clear();
Console.WriteLine("-----------Add Flight----------");
Console.Write("Please enter the flight number:");
flightNo = Convert.ToInt32(Console.ReadLine());
Console.Write("Please the maximum number of seats:");
maxSeats = Convert.ToInt32(Console.ReadLine());
Console.Write("Please enter the port of Origin:");
origin = Console.ReadLine();
Console.Write("Please enter the destination port:");
destination = Console.ReadLine();
if(aCoord.addFlight(flightNo, origin, destination, maxSeats))
{
Console.WriteLine("Flight successfully added..");
}
else
{
Console.WriteLine("Flight was not added..");
}
Console.WriteLine("nPress any key to continue return to the main menu.");
Console.ReadKey();
}
publicstaticvoid showMainMenu()
{
Console.Clear();
Console.WriteLine("XYZ AirLines Limited.nPlease select a choice from the menu below:n");
Console.WriteLine("1: Add Flightn2 :Add Customern3: View Flightsn4: View Customers");
Console.WriteLine("5: Delete Customern6: Delete Flight");
Console.WriteLine("7:Exit");
}
publicstaticint getValidChoice()
{int choice;
showMainMenu();
while (!int.TryParse(Console.ReadLine(),out choice) || (choice 7))
{
showMainMenu();
Console.WriteLine("Please enter a valid choice:");
}
return choice;
}
publicstatic void runProgram()
{
int choice= getValidChoice();
while (choice != 7)
{
if (choice == 1) { addFlight(); }
if (choice == 2) { }
if (choice == 3) { viewFlights(); }
if (choice == 4) { }
if (choice == 5) { }
if (choice == 6) { deleteFlight(); }
choice = getValidChoice();
}
}
staticvoid Main(string[] args)
{
aCoord =new AirlineCoordinator(100, 2, 30);
runProgram();
Console.WriteLine("Thank you for using XYZ Airlines System. Press any key to exit.");
Console.ReadKey();
}
}