01: package com.db4o.f1.chapter3;
02:
03: import java.util.*;
04:
05: public class Car {
06: private String model;
07: private Pilot pilot;
08: private List history;
09:
10: public Car(String model) {
11: this (model, new ArrayList());
12: }
13:
14: public Car(String model, List history) {
15: this .model = model;
16: this .pilot = null;
17: this .history = history;
18: }
19:
20: public Pilot getPilot() {
21: return pilot;
22: }
23:
24: public void setPilot(Pilot pilot) {
25: this .pilot = pilot;
26: }
27:
28: public String getModel() {
29: return model;
30: }
31:
32: public List getHistory() {
33: return history;
34: }
35:
36: public void snapshot() {
37: history.add(new SensorReadout(poll(), new Date(), this ));
38: }
39:
40: protected double[] poll() {
41: int factor = history.size() + 1;
42: return new double[] { 0.1d * factor, 0.2d * factor,
43: 0.3d * factor };
44: }
45:
46: public String toString() {
47: return model + "[" + pilot + "]/" + history.size();
48: }
49: }
|