hi all
Can anyone understand me how i can solve this program ?
I understand its idea and I solved the first class "Vehicle" But stopped at the other classes
( class "Vehicle" is under the question )
The aim of the project is to write two applications: one for Car Rent Company, the other one is for Bus Company. The class Vehicle is going to be used as a super class for the two companies i.e. The Car.java and Bus.java are going to implement the Vehicle. Each one of them is going to reuse the Vehicle differently according to the company needs.
Write a program that contains the following classes:
1) Create a class called Vehicle that contains fields for the vehicle's licensePlateNumber, maker and modelName. Provide both a default constructor and 3 argument constructor. Provide accessor (get) and mutator (set) methods for the fields.
2) Create a subclass of Vehicle called Car that contains a field for the car availability in the Garage (to show it is avilable to use or it is already rented).
3) Create a subclass of Vehicle called Bus that contains fields for the number of seats and number of avilable seats in the Bus.
4) Write two main applications. First one creates a menu for the Car Company and declares an array of 3 cars; the second application creates a menu for the Bus Company and declares an array of 3 Buses. An example for the array declarations:
Car [] mycar = {
New Car("123AAA","Toyota","Corolla"),
New Car("1432BBB","Honda","Stream","") , new Car("121BCA","Toyota","Avalon")
};
Bus [] mybus = {
new Bus("787FFF","Toyota"," HIACE "),
new Bus("909GGB","Ford","Flex",""), new Bus("888YKL","ryanbus","AECMerlin") };
5) Bothe menu should allow its users to add and delete a new car or a new bus. The Car Company menu should give an option to rent a car from the Garage. This is done by changing the value of the car availability. On the other hand, the Bus Company will have an option in the menu to reserve a seat based on the number of seats that are avilable on the bus.
Welcome to Car Company
Main Menu
1. Add a new car.
2. Delete a car.
3. Rent a car
4. Exit.
Welcome to Bus Company
Main Menu
1. Add a new bus.
2. Delete a bus.
3. Reserve a seat.
4. Exit.
Hints1: to rent a car (option3 in the menu), you should display all the cars in the array, the user will select one then you check if this car is avilable in the garage. If it is avilable then set its availability value to indicate that this car is used now.
Hints2: to reserve a seat (option3 in bus menu), you should display all the buses in the array, then the user will select one then you check if there are enough seats still exit. Then you subtract the number of avilable seats by1.
class "Vehicle" :
public class Vehicle { private int licensePlateNumber ; private String maker; private String modelName; public Vehicle(int licensePlateNumber,String maker,String modelName) { this.licensePlateNumber=licensePlateNumber; this.maker=maker; this.modelName=modelName; } public Vehicle() { } public void setLicensePlateNumber(int LPN) { licensePlateNumber=LPN; } public void setMaker(String m) { maker=m; } public void setModelName(String MN) { modelName=MN; } public int getLicensePlateNumber() { return licensePlateNumber; } public String getMaker() { return maker; } public String getModelName() { return modelName; } }