Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

create a vehicle hire company

  Asked By: Mali    Date: Jun 11    Category: Java    Views: 737
  

What i have to do is create a vehicle hire company. The program
should allow you to enter cars and vans (both with different
attributes), allocate a vehicle to a customer, display the vehicle
information etc... i have got so far in the program but i am now
getting confused.

I have implemented a MVC (model view controller) stucture to the
assignment. however inside my controller i am creating one instance
of vehicle (with no args) and then further down i am adding a car to
the vehicle class.

The reason i am confused is because in my vehilce class i am creating
2 vectors to store the cars and the vans in (car and van classes
inherit from vehicle) but i want to be able to store both vans and
cars into one vector and then later determine what the object type is
i.e. instanceof to display the information to screen. i am not sure
if i should be creating more that one vehicle class i.e. a vehicle
class for each car/van or what ?

what about polymorphism could this be used in the program. here is a
bit of code from different classes.

VEHICLE CLASS

public void initialise() {
carVector = new Vector(1,1);
vanVector = new Vector(1,1);
}

public void addCar(String make, String regNo, String colour, int
noOfDoors) {
carVector.add(new Car(make, regNo, colour, noOfDoors));
}

public void addVan(String make, String regNo, double carryCapacity) {
vanVector.add(new Van(make, regNo, carryCapacity));
}

CONTROLLER CLASS

private void createVehicle() {
vehicle = new Vehicle();
vehicle.initialise();
}

private void addCar() {
String make = output.getMake();
String regNo = output.getRegNo();
String colour = output.getColour();
int noOfDoors = output.getNoOfDoors();

vehicle.addCar(make, regNo, colour, noOfDoors);
}

private void addVan() {
String make = output.getMake();
String regNo = output.getRegNo();
double carryCapacity = output.getCarryCapacity();

vehicle.addVan(make, regNo, carryCapacity);
}

ALSO the vehicle class does not contain a constructor. well not one
ive defined anyway.

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on create a vehicle hire company Or get search suggestion and latest updates.




Tagged: