Flight Simulation
VerifiedAdded on  2019/09/16
|3
|1103
|356
Project
AI Summary
The assignment requires you to create a class called FlightSimulation that can simulate an aeroplane's journey from one destination to another based on its speed and coordinates. The aeroplane can travel to different destinations, and its total distance travelled will be updated accordingly. You also need to make the aeroplane repeat its daily schedule of four single flights over 120 days, considering when it needs to undergo repairs.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
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
via Coordinates. This has an x, which is the value along the x-axis (on a map) of
the location, and similarly a y, for the y-axis. These are both whole numbers. (1 mark)
2. A Destination represents the town or city that an aeroplane can travel to. It has
a name and coordinates. (1 mark)
3. An Aeroplane has:
o A name.
o A coordinates.
o A speed, which specifies how far the aeroplane can move in one hour in both the x-
axis and the y-axis.
o The totalDistance that 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.
o A repairDistance, which is the distance that the areoplane can travel before it
must be taken away for 7 days to undergo repairs.
(1 mark)
4. An Aeroplane can take a singleFlight which will attempt to move the aeroplane
towards a supplied destination. This will also calculate and return the distance
travelled in this single journey. The aeroplane moves towards its destination as
follows:
1. The 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.
2. The 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's speed, the x coordinate is
increased by only the distance left to travel. Otherwise, the x coordinate is increased
by the speed of the aeroplane.
3. The 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.
4. The 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 also
be returned.
A visualisation of an example journey made by the aeroplane can be found here. (2
marks)
2. Create a class FlightSimulation, 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 a Destination and name the variable holding it destination1. Set its
attributes as follows:
1. The location, of a destination or an aeroplane (at any point in time), is specified
via Coordinates. This has an x, which is the value along the x-axis (on a map) of
the location, and similarly a y, for the y-axis. These are both whole numbers. (1 mark)
2. A Destination represents the town or city that an aeroplane can travel to. It has
a name and coordinates. (1 mark)
3. An Aeroplane has:
o A name.
o A coordinates.
o A speed, which specifies how far the aeroplane can move in one hour in both the x-
axis and the y-axis.
o The totalDistance that 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.
o A repairDistance, which is the distance that the areoplane can travel before it
must be taken away for 7 days to undergo repairs.
(1 mark)
4. An Aeroplane can take a singleFlight which will attempt to move the aeroplane
towards a supplied destination. This will also calculate and return the distance
travelled in this single journey. The aeroplane moves towards its destination as
follows:
1. The 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.
2. The 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's speed, the x coordinate is
increased by only the distance left to travel. Otherwise, the x coordinate is increased
by the speed of the aeroplane.
3. The 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.
4. The 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 also
be returned.
A visualisation of an example journey made by the aeroplane can be found here. (2
marks)
2. Create a class FlightSimulation, 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 a Destination and name the variable holding it destination1. Set its
attributes as follows:
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
o the name as Ottawa
o the x coordinate as 70
o the y coordinate as 80
(1 mark)
2. Create a Destination and name the variable holding it destination2. Set its
attributes as follows:
o the name as Marrakesh
o the x coordinate as 20
o the y coordinate as 40
(1 mark)
3. Create a Destination and name the variable holding it destination3. Set its
attributes as follows:
o the name as York
o the x coordinate as 10
o the y coordinate as 30
(1 mark)
4. Create an Aeroplane and name the variable holding it aeroplane. Set its attributes
as follows:
o the name as Spitfire
o the x coordinate as 70
o the y coordinate as 80
o the speed as 23
o the totalDistance as 0
o the repairDistance as 4900
(1 mark)
5. Make your aeroplane simulate its journeys in a single day, by doing the following:
1. Print the name of your aeroplane and the journey start destination (which
is destination1) and the journey end destination, which is destination2. Make
your aeroplane take a single flight todestination2. Then, print this single journey's
distance and the total distance travelled by your aeroplane. Finally, print your
aeroplane's current location coordinates.
2. Print the name of your aeroplane and the journey start destination (which is
now destination2) and the journey end destination, which is destination3.
Make your aeroplane take a single flight todestination3. Then, print this single
journey's distance and the total distance travelled by your aeroplane. Finally, print
your aeroplane's current location coordinates.
3. Print the name of your aeroplane and the journey start destination (which is
now destination3) and the journey end destination, which is destination2.
Make your aeroplane take a single flight todestination2. Then, print this single
journey's distance and the total distance travelled by your aeroplane. Finally, print
your aeroplane's current location coordinates.
o the x coordinate as 70
o the y coordinate as 80
(1 mark)
2. Create a Destination and name the variable holding it destination2. Set its
attributes as follows:
o the name as Marrakesh
o the x coordinate as 20
o the y coordinate as 40
(1 mark)
3. Create a Destination and name the variable holding it destination3. Set its
attributes as follows:
o the name as York
o the x coordinate as 10
o the y coordinate as 30
(1 mark)
4. Create an Aeroplane and name the variable holding it aeroplane. Set its attributes
as follows:
o the name as Spitfire
o the x coordinate as 70
o the y coordinate as 80
o the speed as 23
o the totalDistance as 0
o the repairDistance as 4900
(1 mark)
5. Make your aeroplane simulate its journeys in a single day, by doing the following:
1. Print the name of your aeroplane and the journey start destination (which
is destination1) and the journey end destination, which is destination2. Make
your aeroplane take a single flight todestination2. Then, print this single journey's
distance and the total distance travelled by your aeroplane. Finally, print your
aeroplane's current location coordinates.
2. Print the name of your aeroplane and the journey start destination (which is
now destination2) and the journey end destination, which is destination3.
Make your aeroplane take a single flight todestination3. Then, print this single
journey's distance and the total distance travelled by your aeroplane. Finally, print
your aeroplane's current location coordinates.
3. Print the name of your aeroplane and the journey start destination (which is
now destination3) and the journey end destination, which is destination2.
Make your aeroplane take a single flight todestination2. Then, print this single
journey's distance and the total distance travelled by your aeroplane. Finally, print
your aeroplane's current location coordinates.
4. Print the name of your aeroplane and the journey start destination (which is
now destination2) and the journey end destination, which is destination1.
Make your aeroplane take a single flight todestination1. Then, print this single
journey's distance and the total distance travelled by your aeroplane. Finally, print
your aeroplane's current location coordinates.
(1 mark)
6. Now, repeat the aeroplane's daily schedule of four single flights (as specified in the
previous question) over 120 days. Guidelines for this are as follows:
1. Print the current day's number. Then, print the total distance travelled by the
aeroplane up until the start of the day.
2. Now make your aeroplane complete it's daily schedule of four single flights. However,
the daily schedule should only begin if the aeroplane has not travelled so far a total
distance that it needs to be sent for repairs. When the aeroplane does need to go for
repairs, it must not take any flights for 7 days and its total distance travelled is reset to
0.
3. Once the 120 days have been completed, print out the number of times that the
aeroplane had to undergo repairs.
(2 marks)
now destination2) and the journey end destination, which is destination1.
Make your aeroplane take a single flight todestination1. Then, print this single
journey's distance and the total distance travelled by your aeroplane. Finally, print
your aeroplane's current location coordinates.
(1 mark)
6. Now, repeat the aeroplane's daily schedule of four single flights (as specified in the
previous question) over 120 days. Guidelines for this are as follows:
1. Print the current day's number. Then, print the total distance travelled by the
aeroplane up until the start of the day.
2. Now make your aeroplane complete it's daily schedule of four single flights. However,
the daily schedule should only begin if the aeroplane has not travelled so far a total
distance that it needs to be sent for repairs. When the aeroplane does need to go for
repairs, it must not take any flights for 7 days and its total distance travelled is reset to
0.
3. Once the 120 days have been completed, print out the number of times that the
aeroplane had to undergo repairs.
(2 marks)
1 out of 3
Your All-in-One AI-Powered Toolkit for Academic Success.
 +13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
© 2024  |  Zucol Services PVT LTD  |  All rights reserved.