📄 vehicle.java
字号:
/**
* Created by IntelliJ IDEA.
* User: Ray
* Date: 2008-4-8
* Time: 0:01:14
* To change this template use File | Settings | File Templates.
*/
package vehicleinfo;
import java.io.Serializable;
import java.util.ArrayList;
public class Vehicle implements Serializable,Comparable<Vehicle> {
private String vehicleType;
private String registration;
private String colour;
private double curruntMileage;
private double newMileage;
private String hireState;
public Vehicle(String vehicleType, String registration, String colour,double curruntMileage){
this.vehicleType=vehicleType;
this.registration=registration;
this.colour=colour;
this.curruntMileage=curruntMileage;
newMileage=0;
hireState="Unhired";
}
public String getVehicleType() {
return vehicleType;
}
public void resetVehicleType(String type){
this.vehicleType=type;
}
public String getRegistration() {
return registration;
}
public void resetRegistration(String registration){
this.registration=registration;
}
public String getColour() {
return colour;
}
public void resetColour(String colour){
this.colour=colour;
}
public boolean isHired() {
if(hireState.equals("Hired"))
return true;
else return false;
}
public void resetHireState(String hireState) {
this.hireState=hireState;
}
public double getNewMileage() {
return newMileage;
}
public void resetNewMileage(double newMileage) {
this.newMileage = newMileage;
}
public double getCurruntMileage() {
return curruntMileage;
}
public void resetCurruntMileage(double newMileage) {
curruntMileage=newMileage;
}
public String getHireState() {
return hireState;
}
public int compareTo(Vehicle vehicle) {
int compare=this.getHireState().compareTo(vehicle.getHireState());
if(compare!=0) return compare;
compare=this.getVehicleType().compareTo(vehicle.getVehicleType());
if(compare!=0) return compare;
compare=this.getRegistration().compareTo(vehicle.getRegistration());
if(compare!=0) return compare;
return this.getColour().compareTo(vehicle.getColour());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -