Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In the following exercise you should create a number of classes to solve a probl

ID: 3663672 • Letter: I

Question

In the following exercise you should create a number of classes to solve a problem. The exercise description is rather vague, more of a sketchy scenario than a concrete problem specification. Your task is to create the necessary classes to simulate this scenario. All classes should be properly documented and encapsulated. Your task is to create a programming system for a ferry. The ferry transports passengers and vehicles (cars, busses, lorries and bicycles). The ferry has space for 200 passengers and 40 cars. A lorry needs as much space as two busses or 8 cars. A car needs as much space as 5 bicycles. There are different fees for different vehicles and an extra fee might be added for passengers. Use the following fees: Passenger without vehicle, 20 kr. Bicycle 40 kr (passenger included). Car 100 kr + 15 kr/passenger (maximum 4 passengers). Bus 200 kr + 10 kr/ passenger (maximum 20 passengers). Lorry 300 kr + 15 kr/ passenger (maximum 2 passengers). Each type of vehicle (car, bus, lorry, bicycle) will inherit from the class Vehicle. The functionality of the ferry is given by the interface Ferry : A vehicle cannot leave the ferry until the ferry has been disembarked and the same vehicle cannot embark twice. The ferry iterator should iterate over all vehicles embarked (not the passengers). Also write a program FerryMain.java, embarking a number of vehicles and passengers, showing the functionality of the methods.

Explanation / Answer

public abstract class Vehicle implements Ferry { 02       03     public int car; 04     public int lorry; 05     public int bus; 06     public int bicycles; 07     public int passengers; 08       09     public Vehicle(int p, int numCar,int numBus, int numLorry,int numBicycles ){ 10          passengers = p; 11          car = numCar; 12          bus = numBus; 13          lorry = numLorry; 14          bicycles = numBicycles; 15     }       16 17 public int countPassengers() { 18           if (passengers
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote