Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

This should be answered in Java Flight Exercise Write a class called Flight that contains instance data to represent the airline name, flight number, and

This should be answered in Javaimage text in transcribedimage text in transcribed

Flight Exercise Write a class called Flight that contains instance data to represent the airline name, flight number, and the flight's origin and destination cities. Define the flight constructor to accept or initialize all instance data. Include mutator(setter) methods for all instance data, and a toString method that returns the data of the Flight. Create a static variable to keep track of the number of flight objects and a static method to return the number of flights recorded. Create a driver class called FlightTest, whose main method instantiates and updates several Flight objects. In the Flight class you will need: Private members of the class to store the airline name, flight number, flight origin and destination cities A static variable to store the number of Flight objects Two constructors: The first constructor should not accept any values during instantiation (This constructor can initialize the members to an empty string or dash-ie. o or 0) o The second constructor should accept all values for the members during instantiation. o The static variable should be incremented in each version of the constructor Mutator methods for each member of the class You will need these to pass values to the second object. A static method to return the number of flights o This will also serve as the accessor example A toString method to output the information on each flight In the FlightTest driver, you will need: At least two flight objects At least one object must be initialized with the constructor that accepts no parameters At least one object can be "hardcoded" by passing values through the constructor A Scanner object to get information for one (or more) of the objects Local variables (as needed) to store information To referene the mutators for one of your objects To reference the static method created in the class A sample of the output is shown below. (Output does not have to be exact - you can create any situation that you like but your code must be able to show successful use of all components of the class and driver programs.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions