CODE
/**
* Class WaterTank - a simple mode of a water tank, that has
* inflows and outflows, designed to illustrate the concepts
* of classes, objects and methods.
*/
public class WaterTank
{
private int volume;
private int tankID;
private String tankName;
private int capacity;
private boolean isFull;
private int numInflows;
private int numOutflows;
private int MaximumVolume;
private int MinimumVolume;
public WaterTank(String tName, int tID, int vol, int cap)
{
volume = vol;
tankID = tID;
tankName = tName;
numInflows = 1;
capacity = cap;
MaximumVolume = volume;
MinimumVolume = volume;
}
public int getVolume()
{
return volume;
}
public void inflow(int amount)
{
volume = volume + amount;
numInflows = numInflows + 1;
if (volume > MaximumVolume) {
MaximumVolume = volume;
}
}
public void outflow(int amount)
{
volume = volume - amount;
numOutflows = numOutflows + 1;
if (volume < MinimumVolume) {
MinimumVolume = volume;
}
}
public int getTotalInflows()
{
return numInflows;
}
public int getTotalOutflows()
{
return numOutflows;
}
public boolean isFull()
{
if (volume >= capacity) {
return true;
} else {
return false;
}
}
public int getMaximumVolume()
{
return MaximumVolume;
}
public int getMinimumVolume()
{
return MinimumVolume;
}
public int draining(double rate)
{
int seconds;
int x = volume - capacity;
double y = rate;
seconds = (int) (x/y);
return seconds;
}
}
* Class WaterTank - a simple mode of a water tank, that has
* inflows and outflows, designed to illustrate the concepts
* of classes, objects and methods.
*/
public class WaterTank
{
private int volume;
private int tankID;
private String tankName;
private int capacity;
private boolean isFull;
private int numInflows;
private int numOutflows;
private int MaximumVolume;
private int MinimumVolume;
public WaterTank(String tName, int tID, int vol, int cap)
{
volume = vol;
tankID = tID;
tankName = tName;
numInflows = 1;
capacity = cap;
MaximumVolume = volume;
MinimumVolume = volume;
}
public int getVolume()
{
return volume;
}
public void inflow(int amount)
{
volume = volume + amount;
numInflows = numInflows + 1;
if (volume > MaximumVolume) {
MaximumVolume = volume;
}
}
public void outflow(int amount)
{
volume = volume - amount;
numOutflows = numOutflows + 1;
if (volume < MinimumVolume) {
MinimumVolume = volume;
}
}
public int getTotalInflows()
{
return numInflows;
}
public int getTotalOutflows()
{
return numOutflows;
}
public boolean isFull()
{
if (volume >= capacity) {
return true;
} else {
return false;
}
}
public int getMaximumVolume()
{
return MaximumVolume;
}
public int getMinimumVolume()
{
return MinimumVolume;
}
public int draining(double rate)
{
int seconds;
int x = volume - capacity;
double y = rate;
seconds = (int) (x/y);
return seconds;
}
}