diff options
author | Christopher Baines <cbaines8@gmail.com> | 2012-01-25 13:53:22 +0000 |
---|---|---|
committer | Christopher Baines <cbaines8@gmail.com> | 2012-01-25 13:53:22 +0000 |
commit | abcbffd80637a8aea379e6a774aa5747fd5cd0c7 (patch) | |
tree | e6912fb2fe412fd36b989af26be1051dbbf1a27e /src/net/cbaines/suma/Bus.java | |
parent | de2979e0f22264ada8326833bfb39746e9bf78cc (diff) | |
download | southamptonuniversitymap-abcbffd80637a8aea379e6a774aa5747fd5cd0c7.tar southamptonuniversitymap-abcbffd80637a8aea379e6a774aa5747fd5cd0c7.tar.gz |
Lots of changes, need to regenerate the database, and add code to replace old databases with the current one.
Diffstat (limited to 'src/net/cbaines/suma/Bus.java')
-rw-r--r-- | src/net/cbaines/suma/Bus.java | 73 |
1 files changed, 60 insertions, 13 deletions
diff --git a/src/net/cbaines/suma/Bus.java b/src/net/cbaines/suma/Bus.java index 426ee3b..533c43c 100644 --- a/src/net/cbaines/suma/Bus.java +++ b/src/net/cbaines/suma/Bus.java @@ -22,43 +22,90 @@ package net.cbaines.suma; import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.table.DatabaseTable; +/** + * Represents a bus + * + * @author Christopher Baines <cbaines8@gmail.com> + * + */ @DatabaseTable(tableName = "buses") public class Bus { - @DatabaseField(id = true) - public int id; + final static String ID_FIELD_NAME = "id"; + final static String ROUTE_FIELD_NAME = "route"; + final static String DIRECTION_FIELD_NAME = "direction"; - @DatabaseField(canBeNull = true, foreign = true) - Stop lastKnownStop; + @DatabaseField(generatedId = true) + int gid; + + /** + * The identification number of the bus. + */ + @DatabaseField(canBeNull = true) + String id; + /** + * The route the bus is travelling. + */ + @DatabaseField(canBeNull = false, foreign = true) + BusRoute route; + + /** + * The direction which the bus is travelling. + */ @DatabaseField(canBeNull = true, foreign = true) - Stop firstKnownStop; + Direction direction; + /** + * The destination the bus is travelling towards. + */ @DatabaseField(canBeNull = false, foreign = true) - BusRoute lastKnownRoute; + BusStop destination; Bus() { } - Bus(int id, BusRoute lastKnownRoute, Stop lastKnownStop) { + /** + * Create a bus. + * + * @param id + * The identification number of the bus. + * @param route + * The route the bus is travelling. + * @param dir + * The direction which the bus is travelling. + */ + Bus(String id, BusRoute route, Direction dir) { this.id = id; - this.lastKnownRoute = lastKnownRoute; - this.lastKnownStop = lastKnownStop; + this.route = route; + this.direction = dir; } - public Bus(int id, BusRoute lastKnownRoute) { - this(id, lastKnownRoute, null); + /** + * Create a bus. + * + * @param id + * The identification number of the bus. + * @param route + * The route the bus is travelling. + */ + Bus(String id, BusRoute route) { + this(id, route, null); } public String toString() { - return String.valueOf(id); + return String.valueOf(id + " (" + route.code + direction + ")"); + } + + String getName() { + return route.code + direction; } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + id; + result = prime * result + gid; return result; } |