Question
1)Design a class in JAVA called Aircraft with the information found in the file, a default constructor, an overloaded constructor, a copy constructor, all setters
1)Design a class in JAVA called Aircraft with the information found in the file, a default constructor, an overloaded constructor, a copy constructor, all setters and getters
a)Your aircraft class should implement the following methods:
--toString()
--equals(Aircraft ac)
b)When reading data from the file, create objects of type Aircraft and add them to an ArrayList.
c)Design a menu that allows you to add an aircraft, show the information of all aircrafts and delete a specific aircraft (by index). A fourth option exits the program and saves all data from the ArrayList to the same file.
File and code:
Terminal En 8 gy( h(100%) 4) 1:03 AM 12 ubuntu input.xt x chegg.sh x Solution.java x aircraft.dat x new. cpp chegg.cpp main.c x protein.txt x / Solution.java 3 import java.io. blic class Solution e ubuntu@ayushv: /Desktop/codes/cheggsolution blic static void main(Stringt args) throws IOException ubuntu ayushv:-/Desktop/codes/cheggsolutions cat aircraft.dat SR-71 BlackBird 2500 16.95 32.74 M high-speed strategic reconnaissance EF-111A Raven 2280 19.21 23.16 M electronic warfare Concorde 2140 25.61 62.2 C supersonic airlinerubuntugayushv: ubuntu ayushv: ubuntu ayushv:/Desktop/codes/cheggsoLution$ ubuntu ayushv:-/Desktop/codes/cheggsolutions javac Solution.java ubuntu ayushv:-/Desktop/codes/cheggsoLution$ java Solution String name double cruise speed double wingspan; double length; char type; String description; 1e 15 17 19 File file new File("aircraft.dat*); FileInputstream filestream new FileInputstream(file) InputStreamReader inputnew InputStreamReader(fileStream); BufferedReader reader - new BufferedReader(input); 20 /Desktop/codes/cheggsolution String line; top/codes/cheggsoluti // Reading line by line from the // file until a null is returned while((line reader.readLine))!-null) 25 26 27 28 29 Name: SR-71 BlackBird Maximum cruise speed: 2500.0 Wing span: 16.95 Length: 32.74 Type: M Description: high-speed strategic reconnaissance ane Line System.out.println(nName:ane); ne reader. readLine) cruise speed -Double.parseDouble(line); System.out.println("Maximun cruise speed + cruise speed) line reader.readLine) System.out.print("ing span: " Stringll list line.split(+") System.out.println(list(e]) System.out.println "Length: "list[1]): System.out.println "Type: " list[21); line reader.readLine() description line System.out.println("Description: " description); 31 Name: EF-111A Raven Maximum cruise speed : 2288.9 Wing span: 19.21 Length: 23.16 Type: M Description: electronic warfare 35 36 39 Name: Concorde Maximum cruise speed: 2140.0 Wing span: 25.61 Length: 62.2 Type: C Description: supersonic airliner ubuntu ayushv: /D 43 45 codes/cheggsolution Terminal En 8 gy( h(100%) 4) 1:03 AM 12 ubuntu input.xt x chegg.sh x Solution.java x aircraft.dat x new. cpp chegg.cpp main.c x protein.txt x / Solution.java 3 import java.io. blic class Solution e ubuntu@ayushv: /Desktop/codes/cheggsolution blic static void main(Stringt args) throws IOException ubuntu ayushv:-/Desktop/codes/cheggsolutions cat aircraft.dat SR-71 BlackBird 2500 16.95 32.74 M high-speed strategic reconnaissance EF-111A Raven 2280 19.21 23.16 M electronic warfare Concorde 2140 25.61 62.2 C supersonic airlinerubuntugayushv: ubuntu ayushv: ubuntu ayushv:/Desktop/codes/cheggsoLution$ ubuntu ayushv:-/Desktop/codes/cheggsolutions javac Solution.java ubuntu ayushv:-/Desktop/codes/cheggsoLution$ java Solution String name double cruise speed double wingspan; double length; char type; String description; 1e 15 17 19 File file new File("aircraft.dat*); FileInputstream filestream new FileInputstream(file) InputStreamReader inputnew InputStreamReader(fileStream); BufferedReader reader - new BufferedReader(input); 20 /Desktop/codes/cheggsolution String line; top/codes/cheggsoluti // Reading line by line from the // file until a null is returned while((line reader.readLine))!-null) 25 26 27 28 29 Name: SR-71 BlackBird Maximum cruise speed: 2500.0 Wing span: 16.95 Length: 32.74 Type: M Description: high-speed strategic reconnaissance ane Line System.out.println(nName:ane); ne reader. readLine) cruise speed -Double.parseDouble(line); System.out.println("Maximun cruise speed + cruise speed) line reader.readLine) System.out.print("ing span: " Stringll list line.split(+") System.out.println(list(e]) System.out.println "Length: "list[1]): System.out.println "Type: " list[21); line reader.readLine() description line System.out.println("Description: " description); 31 Name: EF-111A Raven Maximum cruise speed : 2288.9 Wing span: 19.21 Length: 23.16 Type: M Description: electronic warfare 35 36 39 Name: Concorde Maximum cruise speed: 2140.0 Wing span: 25.61 Length: 62.2 Type: C Description: supersonic airliner ubuntu ayushv: /D 43 45 codes/cheggsolutionStep by Step Solution
There are 3 Steps involved in it
Step: 1
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