|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--lab2ParkingLot
~mohammad/public_html/classes/csc241/samples/parkingLot/parkingLot.java This is a simple parkingLot class; every ParkingLot object has a capacity of 100 cars and keeps track of its own name and how many cars are currently in it. A parkingLot object is constructed as empty, but willl be given its name. We have mutator methods that enable cars to enter/exit a parkingLot object; remember that we only keep track of how many cars are in a lot. We have an accessor method for the current car count as well as one for the name of the parking lot. The car count for a parkingLot need to be controlled so that it does not exceed capacity or fall below zero. This documentation was generated via javadoc.
Nested Class Summary | |
class |
lab2ParkingLot.lab2ParkingLotOverFlowException
An embedded exception class designed for handeling an illegal call to enter. |
class |
lab2ParkingLot.lab2ParkingLotUnderFlowException
An embedded exception class designed for handeling an illegal call to exit. |
Field Summary | |
int |
capacity_
Constant capacity provides the max capacity for all parking lot |
protected int |
carCount_
Field carCount_ keeps track of the number of cars in a parking lot |
protected java.lang.String |
name_
Field name_ keeps track of the name of a parking lot |
Constructor Summary | |
lab2ParkingLot(java.lang.String n)
Construct a new lab2ParkingLot with 0 cars and the name provided. |
|
lab2ParkingLot(java.lang.String n,
int cap)
Construct a new lab2ParkingLot with 0 cars and the name provided. |
Method Summary | |
int |
capacity()
Return current count of cars for lab2ParkingLot. |
int |
carCount()
Return current count of cars for lab2ParkingLot. |
void |
enter()
increment car count by 1. |
void |
exit()
decrement car count by 1. |
java.lang.String |
name()
Return the name of the lab2ParkingLot. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public int capacity_
protected int carCount_
protected java.lang.String name_
Constructor Detail |
public lab2ParkingLot(java.lang.String n)
public lab2ParkingLot(java.lang.String n, int cap)
Method Detail |
public int carCount()
public int capacity()
public java.lang.String name()
public void enter() throws lab2ParkingLot.lab2ParkingLotOverFlowException
lab2ParkingLot.lab2ParkingLotOverFlowException
public void exit() throws lab2ParkingLot.lab2ParkingLotUnderFlowException
lab2ParkingLot.lab2ParkingLotUnderFlowException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |