📄 car.java
字号:
package com.db4o.f1.chapter4;
import java.util.*;
public class Car {
private String model;
private Pilot pilot;
private List history;
public Car(String model) {
this.model=model;
this.pilot=null;
this.history=new ArrayList();
}
public Pilot getPilot() {
return pilot;
}
public void setPilot(Pilot pilot) {
this.pilot=pilot;
}
public String getModel() {
return model;
}
public SensorReadout[] getHistory() {
return (SensorReadout[])history.toArray(new SensorReadout[history.size()]);
}
public void snapshot() {
history.add(new TemperatureSensorReadout(
new Date(),this,"oil",pollOilTemperature()));
history.add(new TemperatureSensorReadout(
new Date(),this,"water",pollWaterTemperature()));
history.add(new PressureSensorReadout(
new Date(),this,"oil",pollOilPressure()));
}
protected double pollOilTemperature() {
return 0.1*history.size();
}
protected double pollWaterTemperature() {
return 0.2*history.size();
}
protected double pollOilPressure() {
return 0.3*history.size();
}
public String toString() {
return model+"["+pilot+"]/"+history.size();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -