Create a programming system, C/C++ Programming

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.

Posted Date: 3/14/2013 5:53:59 AM | Location : United States







Related Discussions:- Create a programming system, Assignment Help, Ask Question on Create a programming system, Get Answer, Expert's Help, Create a programming system Discussions

Write discussion on Create a programming system
Your posts are moderated
Related Questions
Compiler Design - Limit In The Method Instructions

Aim: To implement a program to maintain information of employees in an educational institute using inheritance. Code:                       class staff {

Aim: To implement a program to allocate memory dynamically for 2 dimensional array (accept and print matrix) using pointers. Code:                       #include #inc

solve for radius(R) of a circle of its area is to be inputted by a user. also display compute the circle diameter hint: area= pir21 pi=2.1416

Within C we access external devices by means of a pointer i.e. address. The address could point to any memory mapped device i.e. Ram, Rom, Duart, Disk drives etc. Therefore there i

Define some Important Point for bit fields with structures? Only n lower bits will be assigned to an n bit number thus type cannot take values larger than 15 (4 bits long)

Develop a function to calculate sum of n even integers starting from a given even integer

Question 1 Write a program that accepts two numbers from the user and swaps the two numbers without using a temporary variable Question 2 Write a program that accepts a 3x

Aim: To implement program to calculate area of cube using inline function. Code: inline void area_cube(float side) {             float area;             are

C Program for DIVISER   void main() {           int result,number,min;           clrscr();           printf("ENTER THE NUMBER=");           flushall();