Commits

littledot5566  committed 272570b

*Refactored Profile and Expedition.

  • Participants
  • Parent commits 23d4595

Comments (0)

Files changed (2)

File src/nctuw/littledot/localtreasure/database/Expedition.java

 
 	private Location mLKLocation = null;
 
+	public Expedition() {
+	}
+
+	public String toString() {
+		String sb = "ID=" + eID + " pID=" + pID;
+
+		if (mStartLoc != null)
+			sb += " stLoc=(" + mStartLoc.getLatitude() + ","
+					+ mStartLoc.getLongitude() + ")";
+		if (mDestLoc != null)
+			sb += " destLoc=(" + mDestLoc.getLatitude() + ","
+					+ mDestLoc.getLongitude() + ")";
+		sb += " dist=" + mDistance
+				+ " tra=" + mTravelled
+				+ " stTS=" + new Date(mStartTS).toString()
+				+ " endTS=" + new Date(mEndTS).toString();
+		if (mPrize != null)
+			sb += " prize=" + mPrize.toString();
+
+		return sb.toString();
+	}
+
+	public long getEID() {
+		return eID;
+	}
+
+	public Expedition setEID(long eID) {
+		this.eID = eID;
+		return this;
+	}
+
+	public long getPID() {
+		return pID;
+	}
+
+	public Expedition setPID(long pID) {
+		this.pID = pID;
+		return this;
+	}
+
+	public Location getStartLoc() {
+		return mStartLoc;
+	}
+
+	public Expedition setStartLoc(Location mStartLoc) {
+		this.mStartLoc = mStartLoc;
+		return this;
+	}
+
+	public Location getDestLoc() {
+		return mDestLoc;
+	}
+
+	public Expedition setDestLoc(Location mDestLoc) {
+		this.mDestLoc = mDestLoc;
+		return this;
+	}
+
+	public float getDistance() {
+		return mDistance;
+	}
+
+	public Expedition setDistance(float mDistance) {
+		this.mDistance = mDistance;
+		return this;
+	}
+
+	public float getTravelled() {
+		return mTravelled;
+	}
+
+	public Expedition setTravelled(float mTravelled) {
+		this.mTravelled = mTravelled;
+		return this;
+	}
+
+	public Expedition incTravelled(float mTravelled) {
+		this.mTravelled += mTravelled;
+		return this;
+	}
+
+	public long getStartTS() {
+		return mStartTS;
+	}
+
+	public Expedition setStartTS(long mStartTS) {
+		this.mStartTS = mStartTS;
+		return this;
+	}
+
+	public long getEndTS() {
+		return mEndTS;
+	}
+
+	public Expedition setEndTS(long mEndTS) {
+		this.mEndTS = mEndTS;
+		return this;
+	}
+
+	public Treasure getPrize() {
+		return mPrize;
+	}
+
+	public Expedition setPrize(Treasure mPrize) {
+		this.mPrize = mPrize;
+		return this;
+	}
+
+	public Location getLKLocation() {
+		return mLKLocation;
+	}
+
+	public Expedition setLKLocation(Location mLKLocation) {
+		this.mLKLocation = mLKLocation;
+		return this;
+	}
+
 	/************/
 	/** SQLite **/
 	/************/
 			+ " integer"
 			+ ");";
 
-	public Expedition() {
-	}
-
 	/**
 	 * Populate an Expedition via a Cursor.
 	 * 
 			setPrize(Treasure.getTreasure(cur.getInt(i)));
 	}
 
-	public String toString() {
-		String sb = "ID=" + eID + " pID=" + pID;
-
-		if (mStartLoc != null)
-			sb += " stLoc=(" + mStartLoc.getLatitude() + ","
-					+ mStartLoc.getLongitude() + ")";
-		if (mDestLoc != null)
-			sb += " destLoc=(" + mDestLoc.getLatitude() + ","
-					+ mDestLoc.getLongitude() + ")";
-		sb += " dist=" + mDistance
-				+ " tra=" + mTravelled
-				+ " stTS=" + new Date(mStartTS).toString()
-				+ " endTS=" + new Date(mEndTS).toString();
-		if (mPrize != null)
-			sb += " prize=" + mPrize.toString();
-
-		return sb.toString();
-	}
-
 	public ContentValues toContentValues() {
 		ArrayList<String> keys = new ArrayList<String>();
 		ArrayList<Object> vals = new ArrayList<Object>();
 		return kv;
 	}
 
-	public long getEID() {
-		return eID;
-	}
-
-	public Expedition setEID(long eID) {
-		this.eID = eID;
-		return this;
-	}
-
-	public long getPID() {
-		return pID;
-	}
-
-	public Expedition setPID(long pID) {
-		this.pID = pID;
-		return this;
-	}
-
-	public Location getStartLoc() {
-		return mStartLoc;
-	}
-
-	public Expedition setStartLoc(Location mStartLoc) {
-		this.mStartLoc = mStartLoc;
-		return this;
-	}
-
-	public Location getDestLoc() {
-		return mDestLoc;
-	}
-
-	public Expedition setDestLoc(Location mDestLoc) {
-		this.mDestLoc = mDestLoc;
-		return this;
-	}
-
-	public float getDistance() {
-		return mDistance;
-	}
-
-	public Expedition setDistance(float mDistance) {
-		this.mDistance = mDistance;
-		return this;
-	}
-
-	public float getTravelled() {
-		return mTravelled;
-	}
-
-	public Expedition setTravelled(float mTravelled) {
-		this.mTravelled = mTravelled;
-		return this;
-	}
-
-	public Expedition incTravelled(float mTravelled) {
-		this.mTravelled += mTravelled;
-		return this;
-	}
-
-	public long getStartTS() {
-		return mStartTS;
-	}
-
-	public Expedition setStartTS(long mStartTS) {
-		this.mStartTS = mStartTS;
-		return this;
-	}
-
-	public long getEndTS() {
-		return mEndTS;
-	}
-
-	public Expedition setEndTS(long mEndTS) {
-		this.mEndTS = mEndTS;
-		return this;
-	}
-
-	public Treasure getPrize() {
-		return mPrize;
-	}
-
-	public Expedition setPrize(Treasure mPrize) {
-		this.mPrize = mPrize;
-		return this;
-	}
-
-	public Location getLKLocation() {
-		return mLKLocation;
-	}
-
-	public Expedition setLKLocation(Location mLKLocation) {
-		this.mLKLocation = mLKLocation;
-		return this;
-	}
-
 	/**************************/
 	/** Interface Parcelable **/
 	/**************************/

File src/nctuw/littledot/localtreasure/database/Profile.java

 	private long mTotalExpeditions;
 	private double mTotalDistance;
 
-	/************/
-	/** SQLite **/
-	/************/
-
-	public static final String TABLE_NAME = "profile";
-	public static final String KEY_ID = "pID";
-	public static final String KEY_NAME = "pName";
-
-	public static final String SQL_CREATE_PROFILE = "create table if not exists "
-			+ TABLE_NAME
-			+ "("
-			+ KEY_ID
-			+ " integer not null primary key autoincrement,"
-			+ KEY_NAME
-			+ " text default '<John Doe>'"
-			+ ");";
-
 	public Profile() {
 	}
 
 				mProfileID, mName, mTotalExpeditions, mTotalDistance);
 	}
 
-	public ContentValues toContentValues() {
-		ArrayList<String> keys = new ArrayList<String>();
-		ArrayList<Object> vals = new ArrayList<Object>();
-
-		keys.add(KEY_ID);
-		vals.add(mProfileID);
-
-		keys.add(KEY_NAME);
-		vals.add(mName);
-
-		return Database.toContentValues(
-				(String[]) keys.toArray(new String[keys.size()]),
-				vals.toArray());
-	}
-
-	public static ContentValues toContentValues(Cursor c) {
-		ContentValues kv = new ContentValues();
-
-		kv.put(KEY_ID, c.getLong(c.getColumnIndex(KEY_ID)));
-		kv.put(KEY_NAME, c.getString(c.getColumnIndex(KEY_NAME)));
-
-		return kv;
-	}
-
 	public long getProfileID() {
 		return mProfileID;
 	}
 		this.mTotalDistance = mTotalDistance;
 	}
 
+	/************/
+	/** SQLite **/
+	/************/
+
+	public static final String TABLE_NAME = "profile";
+	public static final String KEY_ID = "pID";
+	public static final String KEY_NAME = "pName";
+
+	public static final String SQL_CREATE_PROFILE = "create table if not exists "
+			+ TABLE_NAME
+			+ "("
+			+ KEY_ID
+			+ " integer not null primary key autoincrement,"
+			+ KEY_NAME
+			+ " text default '<John Doe>'"
+			+ ");";
+
+	public Profile(Cursor cur) {
+	}
+
+	public ContentValues toContentValues() {
+		ArrayList<String> keys = new ArrayList<String>();
+		ArrayList<Object> vals = new ArrayList<Object>();
+
+		keys.add(KEY_ID);
+		vals.add(mProfileID);
+
+		keys.add(KEY_NAME);
+		vals.add(mName);
+
+		return Database.toContentValues(
+				(String[]) keys.toArray(new String[keys.size()]),
+				vals.toArray());
+	}
+
+	public static ContentValues toContentValues(Cursor c) {
+		ContentValues kv = new ContentValues();
+
+		kv.put(KEY_ID, c.getLong(c.getColumnIndex(KEY_ID)));
+		kv.put(KEY_NAME, c.getString(c.getColumnIndex(KEY_NAME)));
+
+		return kv;
+	}
+
 	/**************************/
 	/** Interface Parcelable **/
 	/**************************/