Class ChemicalTank

java.lang.Object
  |
  +--ChemicalTank

public class ChemicalTank
extends java.lang.Object

ChemicalTank sample class written for a Design By Contract lesson.
ChemicalTank is class containing the basic functionality of a chemical tank with two valves, one on top to fill the tank and one on the bottom to drain the tank. It also contains one sensor that senses whether or not the tank is full.

Created by: Amy Rideg, Judy Tantivongsathaporn


Constructor Summary
ChemicalTank()
          Default constructor.
 
Method Summary
 boolean isTankFull()
          Checks if the tank is full.
 void turnOffBottomValve()
          Turns off, closes, the bottom valve of chemical tank.
 void turnOffTopValve()
          Turns off, closes, the top valve of chemical tank.
 void turnOnBottomValve()
          Turns on, opens, the bottom valve of chemical tank.
 void turnOnTopValve()
          Turns on, opens, the top valve of chemical tank.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChemicalTank

public ChemicalTank()
Default constructor.
Method Detail

turnOnTopValve

public void turnOnTopValve()
Turns on, opens, the top valve of chemical tank.
Precondition:
Tank is not full.
Bottom valve is closed.

Postcondition:
Top valve is open.

turnOffTopValve

public void turnOffTopValve()
Turns off, closes, the top valve of chemical tank.
Precondition:
Top valve is open.
Bottom valve is closed.

Postcondition:
Top valve is closed.

isTankFull

public boolean isTankFull()
Checks if the tank is full.
Returns:
True if the tank is full and false if the tank is not full.

turnOnBottomValve

public void turnOnBottomValve()
Turns on, opens, the bottom valve of chemical tank.
Precondition:
Top valve is closed.

Postcondition:
Bottom valve is open.

turnOffBottomValve

public void turnOffBottomValve()
Turns off, closes, the bottom valve of chemical tank.
Precondition:
Bottom valve is open.
Top valve is closed.

Postcondition:
Bottom valve is closed.