Class lab2ParkingLot

java.lang.Object
  |
  +--lab2ParkingLot

public class lab2ParkingLot
extends java.lang.Object

~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

capacity_

public int capacity_
Constant capacity provides the max capacity for all parking lot


carCount_

protected int carCount_
Field carCount_ keeps track of the number of cars in a parking lot


name_

protected java.lang.String name_
Field name_ keeps track of the name of a parking lot

Constructor Detail

lab2ParkingLot

public lab2ParkingLot(java.lang.String n)
Construct a new lab2ParkingLot with 0 cars and the name provided.


lab2ParkingLot

public lab2ParkingLot(java.lang.String n,
                      int cap)
Construct a new lab2ParkingLot with 0 cars and the name provided.

Method Detail

carCount

public int carCount()
Return current count of cars for lab2ParkingLot.


capacity

public int capacity()
Return current count of cars for lab2ParkingLot.


name

public java.lang.String name()
Return the name of the lab2ParkingLot.


enter

public void enter()
           throws lab2ParkingLot.lab2ParkingLotOverFlowException
increment car count by 1. If car count is already at capacity, this method throws lab2ParkingLotOverFlowException and car count does not change.

lab2ParkingLot.lab2ParkingLotOverFlowException

exit

public void exit()
          throws lab2ParkingLot.lab2ParkingLotUnderFlowException
decrement car count by 1. If car count is at zero, this method throws lab2ParkingLotUnderFlowException and car count stays the same.

lab2ParkingLot.lab2ParkingLotUnderFlowException