Java Program Fleet class- reading from a file called deltafleet.txt-Using file and Scanner Will be creating a file called newfleet.txt Instance Variables: o An array that stores Aircraft that represents Delta Airlines entire fleet o A variable that represents the count for the number of aircraft in the fleet • Methods: o Constructor- One constructor that instantiates the array and sets the count to zero o readFile()- This method accepts a string that represents the name of the file to be read. It will then read the file. Once the data is read, it should create an aircraft and then pass the vehicle to the addAircraft method. It should not allow any duplication of records. Be sure to handle all exceptions. o writeFile()- This method accepts a string that represents the name of the file to be written to and then writes the contents of the array to a file. This method should call a sort method to sort the array before writing to it. o sortArray()- This method returns a sorted array. The array is sorted by registration number.u o addAircraft()- This method accepts an aircraft and adds it to the fleet(the array) only if it is not already in the list. o displayFleet()- This method outputs all of the ships and shuttles that are in the fleet. o displayMaintenanceList()- This method outputs all aircraft in the array that currently require maintenance, either by miles or date. o displayNextMaintenanceList() = This method outputs all aircraft in the fleet by name, manufacturer, model, next maintenance date, and next maintenance miles. o updateMiles()- This method accepts a regNumber and miles and updates the total miles for the designated aircraft based on regNumber o updateMaintenance()- This method accepts a regNumber and changes the lastMaintenance date to the current date and resets last maintenance mileage. o displayAircraft()- This method accepts a regNumber and searches the array for an aircraft that matches that regNumber and displays the information about that vehicle. o removeAircraft()- This method accepts a regNumber and searches the array for that aircraft. For each item that doesn’t match, it will copy the contents to the new array. It will not copy the contents of the aircraft that is found. In other words, all aircraft in the array will be moved up a position to fill in the gap in the array   TextMenu class: • Instance Variables: o An array that stores all of the menu item options • Methods: o Constructor- This accepts an array of menu items- Be sure to create a new array and copy the contents from that array into the text menu array. The array should only display the text options, not the number of the option. o displayMenu()- This method prints the contents of the text menu array. The output should include the number choices for each item. o getChoice()- This method will call the displayMenu and then allow the user to input their response. The response will be sent to the validateChoice() method and then if the choice is valid (not -1), then It will return the integer value of the user’s choice. It must re-ask for input if the choice was not valid. o validateChoice()- This method accepts a string that represents the users choice. This method must use try/catch to convert the string choice to an integer and return -1 if the user does not enter a number or if choice is outside the acceptable range. Otherwise, it should return the choice.     FleetDriver class: • Instance variables: o Scanner instance • main method: o This method should be as minimal as possible and should contain two items:  Instantiate an instance of the Fleet class  Call the setup method • setup()- This method will load the menu items into the array, instantiate an instance of the TextMenu class, call the getChoice method from the TextMenu class and then process the user’s choice. This method should process each option from the menu by calling the appropriate methods. It should repeatedly accept choices until the user chooses to quit. • getAircraftInfo()- This method accepts a numeric representation of the aircraft type and converts the numeric vehicle type to a character type. It should then prompt for and accept all of the other information for an aircraft and then instantiates an Aircraft object and then returns that object. However, you cannot allow the user to enter the last maintenance date that is greater than the current date. If it is greater, the last maintenance date should be set to the current date.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 2GZ
icon
Related questions
Question

Java Program

Fleet class- reading from a file called deltafleet.txt-Using file and Scanner

Will be creating a file called newfleet.txt

Instance Variables:
o An array that stores Aircraft that represents Delta Airlines entire fleet
o A variable that represents the count for the number of aircraft in the fleet
• Methods:
o Constructor- One constructor that instantiates the array and sets the count to zero
o readFile()- This method accepts a string that represents the name of the file to be
read. It will then read the file. Once the data is read, it should create an aircraft and
then pass the vehicle to the addAircraft method. It should not allow any duplication
of records. Be sure to handle all exceptions.
o writeFile()- This method accepts a string that represents the name of the file to be
written to and then writes the contents of the array to a file. This method should
call a sort method to sort the array before writing to it.
o sortArray()- This method returns a sorted array. The array is sorted by registration
number.u
o addAircraft()- This method accepts an aircraft and adds it to the fleet(the array) only
if it is not already in the list.
o displayFleet()- This method outputs all of the ships and shuttles that are in the fleet.
o displayMaintenanceList()- This method outputs all aircraft in the array that currently
require maintenance, either by miles or date.
o displayNextMaintenanceList() = This method outputs all aircraft in the fleet by
name, manufacturer, model, next maintenance date, and next maintenance miles.
o updateMiles()- This method accepts a regNumber and miles and updates the total
miles for the designated aircraft based on regNumber
o updateMaintenance()- This method accepts a regNumber and changes the
lastMaintenance date to the current date and resets last maintenance mileage.
o displayAircraft()- This method accepts a regNumber and searches the array for an
aircraft that matches that regNumber and displays the information about that
vehicle.
o removeAircraft()- This method accepts a regNumber and searches the array for that
aircraft. For each item that doesn’t match, it will copy the contents to the new
array. It will not copy the contents of the aircraft that is found. In other words, all
aircraft in the array will be moved up a position to fill in the gap in the array

 

TextMenu class:
• Instance Variables:
o An array that stores all of the menu item options
• Methods:
o Constructor- This accepts an array of menu items- Be sure to create a new array and
copy the contents from that array into the text menu array. The array should only
display the text options, not the number of the option.
o displayMenu()- This method prints the contents of the text menu array. The output
should include the number choices for each item.
o getChoice()- This method will call the displayMenu and then allow the user to input
their response. The response will be sent to the validateChoice() method and then if
the choice is valid (not -1), then It will return the integer value of the user’s choice.
It must re-ask for input if the choice was not valid.
o validateChoice()- This method accepts a string that represents the users choice. This
method must use try/catch to convert the string choice to an integer and return -1 if
the user does not enter a number or if choice is outside the acceptable range.
Otherwise, it should return the choice.

 

 

FleetDriver class:
• Instance variables:
o Scanner instance
• main method:
o This method should be as minimal as possible and should contain two items:
 Instantiate an instance of the Fleet class
 Call the setup method
• setup()- This method will load the menu items into the array, instantiate an instance of the
TextMenu class, call the getChoice method from the TextMenu class and then process the user’s
choice. This method should process each option from the menu by calling the appropriate
methods. It should repeatedly accept choices until the user chooses to quit.
• getAircraftInfo()- This method accepts a numeric representation of the aircraft type and
converts the numeric vehicle type to a character type. It should then prompt for and accept all
of the other information for an aircraft and then instantiates an Aircraft object and then returns
that object. However, you cannot allow the user to enter the last maintenance date that is
greater than the current date. If it is greater, the last maintenance date should be set to the
current date.  

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 8 steps with 3 images

Blurred answer
Knowledge Booster
Methods of StringBuilder class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage