Model this Scenario Based on Destination or an Aeroplane

Added on - 16 Sep 2019

  • 3


  • 1103


  • 192


  • 0


Trusted by +2 million users,
assist thousands of students everyday
Showing pages 1 to 1 of 3 pages
1.Model this scenario based on the following requirements:1.The location, of a destination or an aeroplane (at any point in time), is specifiedviaCoordinates. This has anx, which is the value along the x-axis (on a map) ofthe location, and similarly ay, for the y-axis. These are both whole numbers. (1 mark)2.ADestinationrepresents the town or city that an aeroplane can travel to. It hasanameandcoordinates. (1 mark)3.AnAeroplanehas:oAname.oAcoordinates.oAspeed, which specifies how far the aeroplane can move in one hour in both the x-axis and the y-axis.oThetotalDistancethat it has travelled. For simplicity, we will assume that thedistance travelled by the aeroplane is the sum of the adjustments made to its xcoordinate plus the adjustments made to its y coordinate, across all of the journeys ithas undertaken. We will not consider the true geometric distance covered.oArepairDistance, which is the distance that the areoplane can travel before itmust be taken away for 7 days to undergo repairs.(1 mark)4.AnAeroplanecan take asingleFlightwhich will attempt to move the aeroplanetowards a supplieddestination. This will also calculate and return the distancetravelled in this single journey. The aeroplane moves towards its destination asfollows:oThe aeroplane keeps moving towards the destination, changing its position everyhour, until its x coordinate matches the x coordinate of the of the destination, and its ycoordinate matches the y coordinate of the destination.oThe x coordinate of the aeroplane is adjusted as follows. It will increase or decrease,depending on whether it is lower or higher, respectively, than the x coordinate of thedestination. The aeroplane should never travel beyond the destination. Therefore,when the distance left to travel is less than the aeroplane'sspeed, the x coordinate isincreased by only the distance left to travel. Otherwise, the x coordinate is increasedby thespeedof the aeroplane.oThe y coordinate of the aeroplane is adjusted in the same way as the x coordinate.Therefore, the aim is to adjust the aeroplane's y coordinate to match the destination'sy coordinate. Again, ensure that the aeroplane never travels beyond the destination.oThe total distance that the aeroplane has travelled (across all of its journeys) must beupdated with the distance of this single journey. The single journey distance must alsobe returned.A visualisation of an example journey made by the aeroplane can be foundhere. (2marks)2.Create a classFlightSimulation, which can be compiled and run from thecommand line. Use this class to do the following (in order), using the classes andmethods you have created for Question 1.1.Create aDestinationand name the variable holding itdestination1. Set itsattributes as follows:
You’re reading a preview
Preview Documents

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Download This Document