Line | Hits | Source |
---|---|---|
1 | package net.sf.tourviewer; | |
2 | ||
3 | import java.util.ArrayList; | |
4 | import java.util.Date; | |
5 | import java.util.List; | |
6 | ||
7 | public class Tour implements Comparable { | |
8 | ||
9 | public enum Type { BIKE, JOGGING, SKI, SKI_BIKE }; | |
10 | ||
11 | private long distance; | |
12 | private Date endTime; | |
13 | private Date startTime; | |
14 | 0 | private List<TourRecord> records = new ArrayList<TourRecord>(); |
15 | 0 | private List<Marker> markers = new ArrayList<Marker>(); |
16 | private Bike bike; | |
17 | private Type type; | |
18 | private long travelTime; | |
19 | ||
20 | 0 | public Tour() |
21 | { | |
22 | 0 | } |
23 | ||
24 | @Override | |
25 | public String toString() | |
26 | { | |
27 | 0 | return getClass().getName() + String.format("[type=%s,distance=%d,startTime=%tF %tT,endTime=%tF %tT]", |
28 | 0 | type, distance, startTime, startTime, endTime, endTime); |
29 | } | |
30 | ||
31 | public void addMarker(Marker marker) | |
32 | { | |
33 | 0 | markers.add(marker); |
34 | 0 | } |
35 | ||
36 | public void addRecord(TourRecord record) | |
37 | { | |
38 | 0 | if (!records.isEmpty()) { |
39 | 0 | TourRecord previous = records.get(records.size() - 1); |
40 | 0 | previous.setNext(record); |
41 | 0 | record.setPrevious(previous); |
42 | ||
43 | 0 | if (record.getDistance() != 0) { |
44 | 0 | travelTime += (record.getTime().getTime() - previous.getTime().getTime()) / 1000; |
45 | } | |
46 | } | |
47 | 0 | records.add(record); |
48 | 0 | } |
49 | ||
50 | public long getDistance() | |
51 | { | |
52 | 0 | return distance; |
53 | } | |
54 | ||
55 | public Date getEndTime() | |
56 | { | |
57 | 0 | return endTime; |
58 | } | |
59 | ||
60 | public Date getStartTime() | |
61 | { | |
62 | 0 | return startTime; |
63 | } | |
64 | ||
65 | public TourRecord[] getRecords() { | |
66 | 0 | return records.toArray(new TourRecord[0]); |
67 | } | |
68 | ||
69 | public void setDistance(long distance) | |
70 | { | |
71 | 0 | this.distance = distance; |
72 | 0 | } |
73 | ||
74 | ||
75 | public void setEndTime(Date endTime) | |
76 | { | |
77 | 0 | this.endTime = endTime; |
78 | 0 | } |
79 | ||
80 | public void setStartTime(Date startTime) | |
81 | { | |
82 | 0 | this.startTime = startTime; |
83 | 0 | } |
84 | ||
85 | ||
86 | public Bike getBike() | |
87 | { | |
88 | 0 | return bike; |
89 | } | |
90 | ||
91 | ||
92 | public Type getType() | |
93 | { | |
94 | 0 | return type; |
95 | } | |
96 | ||
97 | ||
98 | public void setBike(Bike bike) | |
99 | { | |
100 | 0 | this.bike = bike; |
101 | 0 | } |
102 | ||
103 | ||
104 | public void setType(Type type) | |
105 | { | |
106 | 0 | this.type = type; |
107 | 0 | } |
108 | ||
109 | public int compareTo(Object o) | |
110 | { | |
111 | 0 | return getStartTime().compareTo(((Tour)o).getStartTime()); |
112 | } | |
113 | ||
114 | ||
115 | public long getTravelTime() | |
116 | { | |
117 | 0 | return travelTime; |
118 | } | |
119 | ||
120 | ||
121 | public void setTravelTime(long travelTime) | |
122 | { | |
123 | 0 | this.travelTime = travelTime; |
124 | 0 | } |
125 | ||
126 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |