1. Create a Java project called CSIIProject which contains the main class.
2. Create another class of enum type named “Flight”.
a. Declare the enum with 10 distinct values from your choice separated by
a comma. For example:
F1("Dammam", "Beirut", "MEA", "17:20","19:50",2500), F2("Dammam", "Toronto", "Saudia", "12:00","23:15",4200), F3("Dammam", "Beirut", "FlyNas", "10:30","13:10",1800);
b. Create instance variable of type ‘private and final’ named:
Departure, destination, airline, departure_time, arrival_time and price;
c. Create a constructor of type Flight and give values for all the instance variables
d. Create getters for all the instance variables
3. In the class “CSIIProject”: Create a method called “Menu” to ask the user “To terminate, enter 1
To retrieve by Airline , enter 2
To retrieve by Departure city, enter 3
To retrieve by Arrival city, enter 4”
4. In the main of “CSIIProject” class declare the enum Flight as following :
Flight[] flight = Flight.values();
5. Create three methods called byDeparture, byDestination and byAirlines of type void which takes into parameters two variables (Hint: the second variable is the enum). Inside each method, using a loop, display the output.
6. In a loop, call the method “menu” and using Switch statement ask the user to enter the airlines, or the departure City or the Arrival City. The appropriate methods must be called in each switch statement. On the other hand, the ‘default’ is reserved for any invalid input
Your output must me as the following:
run:
Welcome to the project of CS2
To terminate, enter 1
To retrieve by Airline , enter 2
To retrieve by Departure city, enter 3
To retrieve by Arrival city, enter 4
2
Please enter the name of the airline: MEA
Dammam, Beirut, MEA, 17:20, 19:50, 2500
To terminate, enter 1
To retrieve by Airline , enter 2
To retrieve by Departure city, enter 3
To retrieve by Arrival city, enter 4
3
Please enter the departure city DAMMAM
Dammam, Beirut, MEA, 17:20, 19:50, 2500 Dammam, Toronto, Saudia, 12:00, 23:15, 4200 Dammam, Beirut, FlyNas, 10:30, 13:10, 1800
To terminate, enter 1
To retrieve by Airline , enter 2
To retrieve by Departure city, enter 3 To retrieve by Arrival city, enter 4
4
Please enter the arrival city BEIRUT
Dammam, Beirut, MEA, 17:20, 19:50, 2500 Dammam, Beirut, FlyNas, 10:30, 13:10, 1800
To terminate, enter 1
To retrieve by Airline , enter 2
To retrieve by Departure city, enter 3
To retrieve by Arrival city, enter 4 1
Goodbye
1. Create a Java project called CSIIProject which contains the main class. 2. Create another class of enum type named “F
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am