RentalCar.java
/**
A rental car with static methods to count rented and available cars.
*/
public class RentalCar
{
private boolean rented;
private static int ...;
private static int ...;
/**
Constructs a rental car.
*/
public RentalCar()
{
// your work here
}
/**
Get number of cars available
@return count of cars that are available
*/
public static int numAvailable()
{
// your work here
}
/**
Get number of cars rented
@return count of cars that are rented
*/
public static int numRented()
{
// your work here
}
/**
Try to rent this car.
@return true if the car was successfully rented, false if it was already
rented.
*/
public boolean rentCar()
{
// your work here
}
/**
Return rented car.
@return true if the car was previously rented and is now returned,
false if it was not previously rented.
*/
public boolean returnCar()
{
// your work here
}
// This method is used for checking your work. Do not modify it.
public static String check(int n)
{
RentalCar[] cars = new RentalCar[n];
for (int i = 0; i < n; i++)
{
cars[i] = new RentalCar();
}
for (int i = 0; i < n; i = i + 2)
{
cars[i].rentCar();
}
for (int i = 0; i < n; i = i + 3)
{
cars[i].rentCar();
}
for (int i = 0; i < n; i = i + 4)
{
cars[i].returnCar();
}
return RentalCar.numAvailable() + " " + RentalCar.numRented();
}
}