Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You need to program the following classes: MyTravel.java - Class storing the main method. Travel.java - Superclass storing common travel information. AirTravel.java Subclass of
You need to program the following classes: MyTravel.java - Class storing the "main" method. Travel.java - Superclass storing common travel information. AirTravel.java Subclass of Travel specific for air travel. LandTravel.java - Subclass of Travel specific for load travel. Notes that you may add additional methods to any of the classes, but you must follow the specified structure. B.1 Travel Abstract Class Abstract class Travel contains: A protected String data field travelType, either "Air" or "Land". A protected String data field country, e.g. "France", "England", etc. A protected String data field city, e.g. "Paris", "London", etc. A protected String data field travelDate, e.g. "Jan 30 2022". A protected String data field returnDate e.g. "Feb 20 2022". A protected int (or Integer) data field days, e.g. 21. A protected String data field hotel, e.g. "Hilton", "Marriott", etc. A protected double (or Double) data field named cost, e.g. 1500. A private int (or Integer) data field travelMileage, e.g. 2000. A constructor method initializing each data field. Methods set and get for each data field. A print method printing the values of all data fields in the class. B.2 AirTravel Class Class AirTravel contains: A private String data field airline, e.g. "Delta", "United", etc. A private String data field travelRefNumber, e.g. "A123456", etc. A constructor method initializing each data field. Methods set and get for each data field. A print method printing the values of all variables. B.3 Land Travel Class Class Land Travel contains: A private String data field carType, e.g. "Gas", "Electric". A constructor method initializing each data field. Methods set and get for each data field. A print method printing the values of all variables. B.4 MyTravel Class Class MyTravel contains: An "init" method where all travel objects are initiated from data read from the input file and stored inside an array called my Travel. A "print" method printing all the data fields for each travel object, the total travel days and total cost. The "main" method that calls the init and print methods. B.5 ReadTextFile Class The class "ReadTextFile.java" is given to read individual lines from the text file and assign them to objects. B.6 Text Files The input text file "travel.txt" is given consisting of a numerical line stating the number of travel objects to be read from the file. Each line consists of data separated by commas representing each data field for each object. The number of entries in the input file may change when testing the final code, although it will keep the following format for the file: number of travel objects travell_datal, travell_data2.... travel2_datal, travel2_data2, ... travelN_datal, travelN_data2,... For example: 6 Air, France, Paris, Dec 10 2020,Jan 5 2021,5,Delta, Hilton, A123456,1260.50,5000 Air, France, Lyon, Dec 10 2020, Jan 5 2021,6,Southwest Marriott B123456,1260.50,5500 Air, England,London,Dec 5 2020,Jan 1 2021,7,American Airlines, Embassy Suites, C123456,750.00,6000 Land, Canada, Montreal.Dec 30 2020, Jan 30 2021,8,Aloft,380.00,1000,"Gas" Land, Canada, Toronto, Dec 30 2020 Jan 30 2021,8,Marriott,350.00, 1200, "Electric" Air Italy, Rome, Dec 14 2020, Jan 2 2021,7,Delta, Hilton, F123456,1100.00,4500 B.7 Program Output The output format for the above input file should be as follows: Travel Details TravelType: Air Country: France City: Paris TravelDate: Dec 10 2020 ReturnDate: Jan 5 2021 Days: 5 Hotel: Hilton Cost: 1260.5 TravelMileage: 5000 Airline: Delta TravelRefNumber: A123456 TravelType: Air Country: France City: Lyon TravelDate: Dec 10 2020 ReturnDate: Jan 5 2021 Days: 6 Hotel: Marriott Cost: 1260.5 TravelMileage: 5500 Airline: Southwest TravelRefNumber: B123456 TravelType: Air Country: England City: London TravelDate: Dec 5 2020 ReturnDate: Jan 1 2021 Days: 7 Hotel: Embassy Suites Cost: 750.0 TravelMileage: 6000 Airline: American Airlines TravelRefNumber: C123456 TravelType: Land Country: Canada City: Montreal TravelDate: Dec 30 2020 ReturnDate: Jan 30 2021 Days: 8 Hotel: Aloft Cost: 380.0 TravelMileage: 1000 CarType: "Gas" TravelType: Land Country: Canada City: Toronto TravelDate: Dec 30 2020 ReturnDate: Jan 30 2021 Days: 8 Hotel: Marriott Cost: 350.0 TravelMileage: 1200 CarType: "Electric" TravelType: Air Country: Italy City: Rome TravelDate: Dec 14 2020 ReturnDate: Jan 2 2021 Days: 7 Hotel: Hilton Cost: 1100.0 TravelMileage: 4500 Airline: Delta TravelRefNumber: F123456 Total Days: 41 Total Cost: $5101.0 Total Travel Air Mileage: 21000 Total Travel Land Mileage: 2200
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Traveljava public abstract class Travel protected String travelType protected String country protect...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started