📄 scotiaairlinesmain.java
字号:
import java.io.*;
public class ScotiaAirlinesMain
{
private static Keyboard kb = new Keyboard();
private static UserInterface ui = new UserInterface();
private static char menuChoice;
private static Flight aFlight = new Flight(6,4);
public static void main (String args[]) throws IOException
{
String filename;
filename = kb.getString("Enter input filename (RETURN for no input file) > ");
if (filename.length() != 0)
aFlight.loadFromFile(filename);
// endif
do {
ui.displayMainMenu();
menuChoice = Character.toUpperCase(kb.getChar("\n\t\tMake your selection > "));
switch (menuChoice)
{
case '1' : flightAdmin();
break;
case '2' : bookings();
break;
case '3' : aFlight.viewSeat(
kb.getString("\n\t\tEnter seat number >"));
break;
case '4' : aFlight.displayFlightInfo();
aFlight.displaySeatingPlan();
break;
} // endswitch
}while (menuChoice != 'Q');
filename = kb.getString("Enter output filename (RETURN = no output file) > ");
if (filename.length() != 0)
aFlight.saveToFile(aFlight.getDate()+".txt");
// endif
} // endmain
private static void flightAdmin() throws IOException
{
do {
ui.displayAdminMenu();
menuChoice = Character.toUpperCase(kb.getChar("\n\t\tMake your selection > "));
switch (menuChoice)
{
case '1' : enterFlightDetails();
break;
case '2' : changeFlightStatus();
break;
} // endswitch
}while (menuChoice != 'R');
}
private static void enterFlightDetails() throws IOException
{
String flightString;
do {
ui.displayFlights();
menuChoice = Character.toUpperCase(kb.getChar("\n\t\tMake your selection > "));
switch(menuChoice)
{
case '1' : aFlight.setFlightDetails("SA123", "GLA", "BRR");
break;
case '2' : aFlight.setFlightDetails("SA124", "BRR", "GLA");
break;
case '3' : aFlight.setFlightDetails("SA234", "GLA", "BEB");
break;
case '4' : aFlight.setFlightDetails("SA235", "BEB", "GLA");
break;
case '5' : aFlight.setFlightDetails("SA345", "GLA", "SYY");
break;
case '6' : aFlight.setFlightDetails("SA346", "SYY", "GLA");
break;
}// endswitch
}while (menuChoice != 'R');
}
private static void changeFlightStatus() throws IOException
{
do {
ui.displayStatusMenu();
menuChoice = Character.toUpperCase(kb.getChar("\n\t\tMake your selection > "));
if (menuChoice != 'R')
aFlight.setFlightStatus(menuChoice);
}while (menuChoice != 'R');
}
private static void bookings () throws IOException
{
char status;
do {
ui.displayBookingsMenu();
if (aFlight.getFreeSeats() == 0)
aFlight.setFlightStatus('5');
// endif
menuChoice = Character.toUpperCase(kb.getChar("\n\t\tMake your selection > "));
switch (menuChoice)
{
case '1' : if(!(aFlight.isBoarding() || aFlight.isClosed())) {
aFlight.updateSeat(kb.getString("\n\t\tEnter seat number to be cancelled >"),"", 0);
aFlight.setFlightStatus('1');
}
else
System.out.println("\n\t\tCancellation too late - "+aFlight.getStatusMessage());
// endif
break;
case '2' : if(!(aFlight.isCheckingIn() || aFlight.isBoarding()
|| aFlight.isClosed() || aFlight.isFull())) {
aFlight.updateSeat(kb.getString("\n\t\tEnter seat number to be reserved >"),kb.getString("\n\t\tEnter the passenger name >"), 1);
}
else
System.out.println("\n\t\tReservations not available - "+aFlight.getStatusMessage());
// endif
break;
case '3' : if(!(aFlight.isBoarding() || aFlight.isClosed() || aFlight.isFull())) {
aFlight.updateSeat(kb.getString("\n\t\tEnter seat number to be booked >"), kb.getString("\n\t\tEnter the passenger name >"), 2);
}
else
System.out.println("\n\t\tBookings not available – "+aFlight.getStatusMessage());
// endif
break;
} // endswitch
}while (menuChoice != 'R');
}
} // end of Scotia AirlinesMain
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -