I need to find a reserved car, I can get the methods to compile but can not get the test to work,
Instead of putting the whole code I am going to only post the significant areas and the error. Again I know it is easy!
public void findReservation(int i)
{
if(LookForReservation(i) == -1)
System.out.println("Rental Car not found");
}
private int LookForReservation(int g)
{
for (int i=0; i<rentCnt; i++)
{
if(theCars.getCarNum()== g)
System.out.println(theCars[i].toString());
else
if(theCars[i].getCarNum()== g);
} return NOT_FOUND;
The lookforreservation method needs to stay private
I need to call the find reservation from the test file, then have that method call the look for and then give results
This is the test file
public class TestRentalCar
{
public static void main(String[] args)
{
RentalCarCompany2 company = new RentalCarCompany2("El Cheapo");
Car car_out1 = new Car("Jessie Brown",1,"Caravan","Dodge",4,42.99,7);
company.addReservation(car_out1);
Car car_out2 = new Car("Tessa Love",2,"Lincoln","Cadillac",4,62.99,3);
company.addReservation(car_out2);
Car car_out3 = new Car("Desiree Statler",3,"Honda","Prelude",2,32.99,5);
company.addReservation(car_out3);
company.printRentalList();
System.out.println("The number of 2 door cars rented is: " + company.getDoorCount2());
System.out.println("The number of 4 door cars rented is: " + company.getDoorCount4());
System.out.println("The average days a car is rented out is: " + company.getAvgDays());
System.out.println("The average rate of a car rental is: " + company.getAvgRate());
System.out.println("The total Rental income for company is: " + company.getTotalRentalSales());
Car rentedcar = company.findReservation(2);
}
}
This is the error that i get when i compile the test file. I am not sure how to fix this. I have tried several things and nothing is working.
----jGRASP exec: javac -g C:\Users\Jessie\Documents\java\class project files\project 6\New Folder\TestRentalCar.java
TestRentalCar.java:36: incompatible types
found : void
required: Car
Car rentedcar = company.findReservation(2);
^
1 error
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
Thanks for the help on last problem, once i realized what i was doing the rest fell into place.
Jess