📄 car.java
字号:
public class Car
{
// Transmission types
public static final int AUTOMATIC = 0;
public static final int TIPTRONIC = 1;
public static final int MANUAL = 2;
// Attributes
protected String typeOfCar;
protected int horsePower;
protected int maximumSpeed;
protected int numberOfDoors;
protected String paint;
protected int gasCapacity;
protected int oilCapacity;
protected int transmission;
// State attributes
protected boolean running = false;
protected int currentSpeed;
protected int currentGas;
protected int currentOil;
public Car( String typeOfCar,
int horsePower,
int maximumSpeed,
int numberOfDoors,
String paint,
int gasCapacity,
int oilCapacity,
int transmission )
{
this.typeOfCar = typeOfCar;
this.horsePower = horsePower;
this.maximumSpeed = maximumSpeed;
this.numberOfDoors = numberOfDoors;
this.paint = paint;
this.gasCapacity = gasCapacity;
this.oilCapacity = oilCapacity;
this.transmission = transmission;
}
public void start()
{
running = true;
}
public void stop()
{
running = false;
}
public boolean isRunning()
{
return running;
}
public void accelerate()
{
currentSpeed += 5;
}
public void decelerate()
{
currentSpeed -= 5;
}
public int getCurrentSpeed()
{
return currentSpeed;
}
public String toString()
{
return typeOfCar;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -