Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is a Java question. (12 points) Write a class Airport. An airport has the following private fields: An int indicating the x-coordinate of the
This is a Java question. (12 points) Write a class Airport. An airport has the following private fields: An int indicating the x-coordinate of the airport on a world map with a scale to 1 km. An int indicating the y-coordinate of the airport on a world map with a scale to 1 km. An int indicating the airport fees (in cents) associated to this airport. The class must also have the following public methods: A constructor that takes three int as input indicating the position of the airport on a map (x and y coordinate) and the fees of the airport in cents) respectively. The constructor uses the inputs to initialize the corresponding fields. A getFees method to retrieve the fees of the airport. A static method getDistance which takes as input two airport and returns a integer indicating the distance in kilometer between the two airports. Note that the method should round the distance up (e.g. both 5.9 and 5.2 should become 6). More over, remember that given two points (1,9) and (22,42), the distance can be computed with the following formula: distance = (1-2) + (y1 - y2)2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started