Create a programming system, C/C++ Programming

Assignment Help:

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 di erent fees for di erent 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)

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 hasRoomForPassenger(); // true if we can embark another passenger
String toString(); // Nice looking ferry status print out
}

A vehicle can not leave the ferry until the ferry has been disembarked and the same vehicle can not 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.


Related Discussions:- Create a programming system

C program for swapping the string, C Program for SWAPPING THE STRING #i...

C Program for SWAPPING THE STRING #include conio.h> #include stdio.h> void main() {           char a[50],temp=0;           int i=0,c=0,c1=0,l=0;           clr

Inverted Index Implementation, Need help finishing my homework. It''s been ...

Need help finishing my homework. It''s been 5 years since I''ve use C++. I am a VN.Net programmer. -Todd

Data types, #question write a prog c & cpp

#question write a prog c & cpp

C program to store all ascii char into a file, Program is to store all ASCI...

Program is to store all ASCII char into a file: void main()     {   ofstream  fout("ascii.txt");   int i,n=256;   for(i=1;i     {     fout     }

Create a program for decision structure , Create the following program or p...

Create the following program or propose one of your own. The program must include at least one of each of the following. Decision structure Repetitive structure fu

Virtual ATM, #questio A charitable organization wants to design a special A...

#questio A charitable organization wants to design a special ATM machine to be used by needy people. The association supplies the needy person with a pin number to be able to use

What if one can''t wrap the local in an artificial block?, What if one can'...

What if one can''t wrap the local in an artificial block?

Ans, A palindrome is a string that reads the same from both the ends. Given...

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

When do employ "const" reference arguments in function?, A: 1.      By u...

A: 1.      By using const protects you against programming errors which inadvertently alter data. 2.      By using const allows function to procedure const and non-const actu

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd