public class Car {
/**
* The color of the car
*
*/
private String color;
/**
* The size of the engine (in litres)
*
*/
private float engineSize;
/**
* The number of people that can fit in the car
*
*/
private int numPeople;
/**
* Indicates whether or not the engine is currently running or
* not.
*
*/
private boolean running;
/**
* Create a new instance with the specified color, engine size and
* capacity.
*
* @param color the color of the car
* @param engineSize the size of car's engine
* @param numPeople the capacity of the car
*
*/
public Car(String color, float engineSize, int numPeople) {
this.color = color;
this.engineSize = engineSize;
this.numPeople = numPeople;
this.running = false;
}
/**
* Return the color of the cor
*
* @return the color of the car
*
*/
public String getColor() {
return color;
}
/**
* Return the engine size of the car.
*
* @return the engine size
*
*/
public float getEngineSize() {
return engineSize;
}
/**
* Return the number of people that can fit in the car.
*
* @return the capacity of the car
*
*/
public int getNumPeople() {
return numPeople;
}
/**
* Return whether or not the engine is currently running.
*
* @return true if the engine is running;
* false otherwise
*
*/
public boolean getRunning() {
return running;
}
/**
* Switch the engine on.
*
**/
public void turnOn() {
running = true;
}
/**
* Switch the engine off.
*
**/
public void turnOff() {
running = false;
}
}
|