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 need as much space as two busses or 8 cars. A car need 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:
Every type of vehicle (car, bus, lorry, bicycle) will inherit from the class Vehicle.
The functionality of the ferry is given by the interface Ferry :public interface Ferry { int countPassengers(); // Number of passengers on board int countVehicleSpace(); // Used vehicle space. One car is 1. int countMoney(); // Earned money Iterator iterator(); // Vehicle iterator void embark(Vehicle v); // Embark vehicle, warning if not enough space void embark(Passenger p); // Embark passenger, warning if not enough room void disembark(); // Clear (empty) ferry. The money earned remains, // i.e., is not reset to zero boolean hasSpaceFor(Vehicle v); // true if we can embark vehicle v boolean hasRoomFor(Passenger p); // true if we can embark passenger p String toString(); // Nice looking ferry status print out
}
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 test program FerryMain.java, embarking a number of vehicles and passengers, showing the functionality of the methods.
Please help me to complete this problem. I totall confused and I need help get start with this problem. I understood the concepts Interfaces and Inheritance but unable start with this problem. Please help me.