Question: Write a complete program that performs the following instructions: Define an Airplane class with a properly defined speed instance variable. Write a default constructor that
Write a complete program that performs the following instructions:
Define an Airplane class with a properly defined speed instance variable.
Write a default constructor that initializes the speed to 5.
Write a method getSpeed() to return the current speed
Write a method called accelerate() that adds 10 to the speed.
Add a constant called TAKEOFF_SPEED to the class and set it to 180.
Write a method called isFlying() that returns true if the speed is greater than or equal to TAKEOFF_SPEED, otherwise false
Create an AirplaneTest class with a method flight() that creates an Airplane object and has a loop that keeps calling that object's accelerate() as long as isFlying() is false.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
