KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > f1 > chapter3 > Car


1 package com.db4o.f1.chapter3;
2
3 import java.util.*;
4
5 public class Car {
6     private String JavaDoc model;
7     private Pilot pilot;
8     private List history;
9
10     public Car(String JavaDoc model) {
11         this(model,new ArrayList());
12     }
13
14     public Car(String JavaDoc 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 JavaDoc 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,0.3d*factor};
43     }
44     
45     public String JavaDoc toString() {
46         return model+"["+pilot+"]/"+history.size();
47     }
48 }
Popular Tags