Amazon Interview Question
Software Engineer / DevelopersClass Building{
List <Floor> floors;
//Member methods
}
class Floor{
List <ParkingLot> parkingLots;
//member Methods
}
class ParkingLot{
Boolean exists;
//member methods
}
Use of Singleton pattern makes sense here since a common parking lot will be shared by all the vehicles, so you might need to incorporate that in your code.
There's also a scope of using Factory method pattern for ParkingLot object depending on the size of the vehicle (although, it might not be necessary)
I can also think of time stamps?
class ParkingLot {
- Sancho Sebastine May 31, 2011private ArrayList<Slot> slots;
int totalFreeSlots;
}
abstract class Slot {
int slotid;
int floorNo;
boolean occupied;
int getHeight();
int getWidth();
}
class CompactSlot extends Slot {
int width=xx;
int height=yy;
}
class LargeSlot extends Slot {
int width=xx;
int height=yy;
}
class DisabledSlot extends Slot {
int width=xx;
int height=yy;
}