Ask a question to Desklib · AI bot


Model this Scenario Based on Destination or an Aeroplane

3 Pages1103 Words356 Views

Added on  2019-09-16

BookmarkShareRelated Documents
1.Model this scenario based on the following requirements:1.The location, of a destination or an aeroplane (at any point in time), is specified viaCoordinates. This has anx, which is the value along the x-axis (on a map) of the 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 has anameandcoordinates. (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 the distance travelled by the aeroplane is the sum of the adjustments made to its x coordinate plus the adjustments made to its y coordinate, across all of the journeys it has undertaken. We will not consider the true geometric distance covered.oArepairDistance, which is the distance that the areoplane can travel before it must be taken away for 7 days to undergo repairs.(1 mark)4.AnAeroplanecan take asingleFlightwhich will attempt to move the aeroplane towards a supplieddestination. This will also calculate and return the distance travelled in this single journey. The aeroplane moves towards its destination as follows:oThe aeroplane keeps moving towards the destination, changing its position every hour, until its x coordinate matches the x coordinate of the of the destination, and its y coordinate 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 the destination. The aeroplane should never travel beyond the destination. Therefore, when the distance left to travel is less than the aeroplane'sspeed, the x coordinate is increased by only the distance left to travel. Otherwise, the x coordinate is increased by 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's y 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 be updated 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. (2 marks)2.Create a classFlightSimulation, which can be compiled and run from the command line. Use this class to do the following (in order), using the classes and methods you have created for Question 1.1.Create aDestinationand name the variable holding itdestination1. Set its attributes as follows:
Model this Scenario Based on Destination or an Aeroplane_1

Found this document preview useful?

Related Documents
Situational Leadership Theory and Kolb's Theory of Experiential Learning