Question: Garage.java package unl.cse.parking; public class Garage { private final Vehicle stalls[]; public Garage(int capacity) { stalls = new Vehicle[capacity]; } /** * Parks the vehicle

 Garage.java package unl.cse.parking; public class Garage { private final Vehicle stalls[];public Garage(int capacity) { stalls = new Vehicle[capacity]; } /** * "Parks"the vehicle in a stall if one is available. Returns true if* the vehicle was added successfully; false otherwise. */ public boolean addVehicle(Vehicle

Garage.java

package unl.cse.parking;

public class Garage {

private final Vehicle stalls[];

public Garage(int capacity) {

stalls = new Vehicle[capacity];

}

/**

* "Parks" the vehicle in a stall if one is available. Returns true if

* the vehicle was added successfully; false otherwise.

*/

public boolean addVehicle(Vehicle automobile) {

//TODO: implement this method

return false;

}

/**

* Remove the vehicle having the provided

* license plate number from the garage. The method returns

* the vehicle if it is found otherwise it returns null.

*/

public Vehicle removeVehicle(String license) {

//TODO: implement this method

return null;

}

/**

* Returns the maximum capacity of this Garage

*/

public int getCapacity() {

return this.stalls.length;

}

/**

* Returns the number of empty stalls in the garage--the number of open

* spots

* @return

*/

public int getNumFreeSpots() {

int freeSpots = 0;

for(int i=0; i

if(stalls[i] == null) {

freeSpots++;

}

}

return freeSpots;

}

/**

* Simulates the passing of a day by adding a day in the garage to each vehicle

* in the garage.

* @return

*/

public void addDay() {

//TODO: implement this

}

public void addDay(int numDays) {

//TODO: optionally implement this as well

}

/**

* Displays the current "state" of the garage by printing out information about each

* stall

*/

public void displayReport() {

System.out.println("Stall License Type Days Total Fee");

for(int i=0; i

if(stalls[i] == null) {

System.out.println(String.format("%3d EMPTY", (i+1)));

} else {

//TODO: You will need to modify these arguments to display the report correctly

System.out.println(String.format("%3d %-10s %-11s %3d $%5.2f", (i+1), stalls[i].getLicense(), "TODO-TYPE", -1, -1.0));

}

}

}

}

GarageStimulation.java

package unl.cse.parking;

public class GarageSimulation {

public static void main(String[] args) {

Garage safePark = new Garage(10);

Vehicle herbie = new Vehicle("OFP 857");

safePark.addVehicle(herbie);

safePark.addDay();

safePark.addDay();

safePark.addDay();

safePark.displayReport();

}

}

Vehicle.java

package unl.cse.parking;

public class Vehicle {

private final String license;

// The class constructor

public Vehicle(String license) {

this.license = license;

}

/**

* The getter method granting public access to reading the

* license plate number. Notice license does not have a

* setter since it cannot be modified.

*/

public String getLicense() {

return license;

}

}

. Lab Objectives & Topics Upon completion of this lab you should be able to .Use inheritance, composition (aggregation), simple polymorphism .Planning, evaluating, and selecting different design strategies to efficiently and effectively solve problems 2. Problem Statement Your company is responsible for designing billing software for a parking garage named SafePark. SafePark has a capacity of 20 vehicles and can service 3 types of vehicles; motorbikes, compact cars, and SUVs. Parking fees are based on the following table

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!