Page 1 of 1

Hi everyone, can someone help me with developing this code please?: /** * The class FlightPlan models a flight plan for

Posted: Fri Jun 10, 2022 11:58 am
by correctanswer
Hi everyone,
can someone help me with developing this code please?:
/**
* The class FlightPlan models a flight plan for an air
journey.
* Complete the class according to the instructions in part
(a)
*/

import java.util.*;
class FlightPlan
{
private String callSign;
/**
* Getter for the call sign of the aircraft
*/
public String getCallSign()
{
return callSign;
}
/**
* A simple equals method
*/
public boolean equals(Object o)
{
FlightPlan f = (FlightPlan) o;

return
getCallSign().equals(f.getCallSign());
}

/**
* return a hash code for this object based on its call
sign
*/
public int hashCode()
{
return callSign.hashCode();
}
}
/**
* This class models Air Traffic Control that oversees flight
plans.
* Complete this class according to the instructions in part
(b)
*/
class AirTrafficControl
{
public TreeSet<FlightPlan> flightPlans; //public
for testing purposes

public TreeSet<FlightPlan>
getFlightPlans()
{
return flightPlans;
}

// Add further code for the AirTrafficControl class
here

}
Scenario Air Traffic Control oversees all
the flight plans of the flights taking off from airports in their
jurisdiction. A flight plan includes the call sign of the
airplane and a list of all of the points on a route, including the
departure and the destination airports, in the order in which they
should be encountered (these points are
called waypoints).

A Waypoint has a name, a coordinate and an altitude.

The class Waypoint (click to view this file) has already
been developed.

Please note that the answer box below
contains two classes to
complete. You can only use import statements at the
top of the answer box.
The answer box below includes some methods of the class
FlightPlan that you should not alter, as well as the
declarations for the fields of the
AirTrafficControl class.
(a) Develop only the class FlightPlan in this part,
which is already partially developed below.
(i) Add a declaration for a private instance variable
called route, which should be declared as a ArrayList containing
elements of type Waypoint.
(ii) Add a public constructor for FlightPlan that takes
one string parameter representing the call sign of the airplane and
initialises the related variable accordingly. The constructor
should also initialise route to a suitable empty
collection.
(iii) Add a standard getter method for the
route collection.
(iv) How to write a public instance method
greatestAltitude that has no parameters and returns the
altitude of the highest waypoint on the route of this flight
plan. You can assume that there are at least three waypoints
on the route.
(v) How to write a public instance method
destination that returns the name of the final waypoint
on the route of this flight plan.
(vi) The air traffic controllers want to be able to sort
flight plans by their call signs in ascending order. Modify
the FlightPlan class so that it implements the appropriate
interface, and then implement the compareTo method that will allow
the ordering required.
(b) Develop only the class AirTrafficControl in
this part, which is already partially developed below.
(i) Add a public AirTrafficControl constructor that
initialises flightPlans to a suitable collection type
(initially empty).
(ii) Add a public method addFlightPlan that adds the
parameter, of type FlightPlan to flightPlans. Nothing is returned
from the method.
(iii) Add a public instance method routeMap that
returns a HashMap in which the keys are the call signs of the
flight plans and each value is an ArrayList of the names of the
waypoints on the corresponding route, in the order in which they
should be encountered.
For example: