Reference no: EM132281186
Object-Oriented Programming Fundamentals Assignment Part B - Angles and lights explained
- To practise using the Math class.
- To practise reading from the console and writing to the screen.
- To practice using switch and/or multiway selection branches.
- To practise using loops (repetition).
What we want the program to do:
We need to write a program, in Java, that will let the pilot issue commands to the aircraft to get it down safely on the flight deck.
The program starts by prompting (asking) the user to enter the (start) approach speed in knots.
A knot is a nautical mile and is the unit used in the navy and by the navy pilots.
After the user enters the approach speed, the user is then shown the menu and the pilot picks a command.
The effect of this command is then calculated and the updated information about the aircraft is displayed. If the aircraft has crashed or has landed, then the information is different.
If the aircraft does not land, overshoot or crash, then the program presents the menu again and the user makes another choice (or the same choice again) and the program calculates the updated position of the aircraft and displays the information to the pilot (the user)'.
This continues until the aircraft successfully lands on the flight desk, the aircraft crashes or the aircraft overshoots the landing area.
To successfully land, the aircraft must have its hook down and its gear down when it is in the valid landing zone.
To be in the correct landing zone with the hook up and gear down, means the aircraft doesn't stop in time and has to go around, this is known as an overshoot.
To be in the correct landing zone with the gear (landing gear) up means that the aircraft crashes. (Whether the hook is up or down doesn't matter).
At any time, the user can issue the command Eject. This displays a message and stops the program, the aircraft crashes into the ocean.
The commands and the changes they make are listed below.
Note that commands must be case insensitive. That is, HOOK Down and hook dOWN must have the same effect.
If the aircraft is still on approach, that is, it hasn't landed, overshot or crashed, the new height is shown along with the distance (which is to the back (stern) of the flight deck) and the glide path angle.
The starting state of the aircraft is gear up, hook up and flaps level.
An invalid command should not change anything about the conditions of the plane.
The commands and their effects are listed below.
Recall that the aircraft is always moving forward at the speed set at the start of the program.
Only certain commands are allowed, these are entered as text (not numbers) Invalid commands should be ignored.
The allowed commands and the change they make:
Gear Up - This increases the height + 20 feet (this is a one off effect) If the gear is already up, then an appropriate message is displayed to the screen and the height is not changed.
Gear Down - This decreases the height 20 feet (this is a one off effect) If the gear is already down, then an appropriate message is displayed to the screen and the height is not changed.
Hook up - This increases the height + 10 feet (this is a one off effect) If the hook is already up, then an appropriate message is displayed to the screen and the height is not changed.
Hook Down - This decreases the height 10 feet (this is a one off effect) If the hook is already down, then an appropriate message is displayed to the screen and the height is not changed.
Flaps Up - This increases the height + 15 feet (this is a one off effect) If the flaps are already fully up, then an appropriate message is displayed to the screen. The height is changed by +15, even if the flaps are already fully up.
Flaps Down - This decreases the height 15 feet (this is a one off effect) If the flaps are already fully down, then an appropriate message is displayed to the screen. The height is changed by - 15, even if the flaps are already fully down.
To go from flaps fully up to flaps fully down requires 2 steps, the first time the Flaps down command is issued the flaps go to level, then the next time the flaps down command is issued, they go to fully down.
If the flaps are level, they do not change the height on the next time through the menu.
This is the same for flaps up, if the flaps are fully down, then the command flaps up brings the flaps to level, the next flaps up command would see the flaps go from level to fully up.
Maintain - This command does not change the height, just flies straight and level. Note that the one thing this command must do is set the flaps to the level position. The distance changes.
Power Up - This command increases the height by 5.
Power Down - This command decreases the height by 5.
Eject - Ends the program, after a screen message.
The distance, angle and height figures must be displayed to 2 decimal places.
Your program must correctly deal with the user entering an invalid command (not one of the commands listed above). If the user enters an invalid command, an appropriate message is displayed to the screen, and nothing is changed, just go straight back to the menu again.
The program ends when the aircraft lands, crashes or overshoots, or the user selects the Eject command.
Attachment:- Assignment File.rar