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
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