Monday, April 18, 2016
Parking Lot -- OOD
enum VehicleSize{
MotoCycle, Compact, Large
}
abstract class Vehicle{
protected ArrayList<ParkingSpot> parkingspots = new ArrayList<ParkingSpot>();
protected String license;
protected int spotsNeeded;
protected VehicleSize size; //enum type VehicleSize
public int getSpotsNeeded(){
return spotsNeeded;
}
public VehicleSize getSize(){
return size;
}
public void parkInSpot(ParkingSpot s){
parkingspots.add(s);
}
public void removeFromSpot(){
}
public abstract boolean canFitInSpot(ParkingSpot spot);
}
class Bus extends Vehicle{
public Bus(){
spotsNeeded = 5;
size = VehicleSize.Large;
}
@Override
public boolean canFitInSpot(ParkingSpot spot){
return true;
}
}
class Car extends Vehicle{
public Car(){
spotsNeeded = 1;
size = VehicleSize.Compact;
}
@Override
public boolean canFitInSpot(ParkingSpot spot){
return true;
}
}
class MotoCycle extends Vehicle{
public MotoCycle(){
spotsNeeded = 1;
size = VehicleSize.MotoCycle;
}
@Override
public boolean canFitInSpot(ParkingSpot spot){
return true;
}
}
public class ParkingLot{
private Level[] levels;
private final int NUM_LEVELS = 5;
public ParkingLot(){
}
public boolean parkVehicle(Vehicle vehicle){
return true;
}
}
class Level{
private int floor;
private ParkingSpot[] spot;
private int availableSpots = 0;
private static final int SPOTS_PER_ROW = 10;
private static final int NUM_OF_ROW = 5;
public Level(int floor, int numberSports){
}
public int getavailableSpots(){
return availableSpots;
}
public boolean parkVehicles(Vehicle vehicle){
return true;
}
private boolean parkStaringAtSpot(int num, Vehicle v){
return true;
}
private int findAvailableSpot(Vehicle v){
return 0;
}
public void spotFreed(){
availableSpots++;
}
}
class ParkingSpot{
private Vehicle vehicle;
private VehicleSize spotSize;
private int row;
private int spotNumber;
private Level level;
public ParkingSpot(Level level, int r, int n, VehicleSize s){
}
public boolean isAvailable(){
return vehicle == null;
}
public boolean canFitVehicle(Vehicle v){
return true;
}
public boolean park(Vehicle v){
return true;
}
public int getRow(){
return row;
}
public int getSpotNumber(){
return spotNumber;
}
public void removeVehicle(){
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment