From 5ad1f3b075a534401c7bcad0ae8b03349f0860fd Mon Sep 17 00:00:00 2001 From: bspeice Date: Mon, 28 Oct 2013 14:58:44 -0400 Subject: [PATCH] Move off the HashMap stuff, stick a ParkingCoordinate inside a ParkingLot --- .../uncc/gameday/parking/ParkingClient.java | 21 ++++++------ .../gameday/parking/ParkingCoordinate.java | 33 +++++++++++++++++++ .../uncc/gameday/parking/ParkingLocation.java | 27 --------------- src/com/uncc/gameday/parking/ParkingLot.java | 7 ++++ src/com/uncc/gameday/rest/GamedayService.java | 13 +++++--- 5 files changed, 59 insertions(+), 42 deletions(-) create mode 100644 src/com/uncc/gameday/parking/ParkingCoordinate.java delete mode 100644 src/com/uncc/gameday/parking/ParkingLocation.java diff --git a/src/com/uncc/gameday/parking/ParkingClient.java b/src/com/uncc/gameday/parking/ParkingClient.java index f9dabcd..ac30b4a 100644 --- a/src/com/uncc/gameday/parking/ParkingClient.java +++ b/src/com/uncc/gameday/parking/ParkingClient.java @@ -44,17 +44,18 @@ public class ParkingClient { gds.rateLot(rating, new ParkingLotCallback()); } - public Map listLotLocation(ParkingLot p){ - HashMap mMap = new HashMap(); - mMap.put(p, gds.listLotLocation(p.getLocation().getValue())); - return mMap; + public ParkingLot listLotLocation(ParkingLot p){ + ParkingCoordinate pc = gds.listLotLocation(p.getLocation().getValue()); + p.setCoordinate(pc); + return p; } - public Map listLotLocation(ParkingChoice c) { - HashMap mMap = new HashMap(); - ParkingLot mParkingLot = new ParkingLot(); - mParkingLot.setLocation(c); - mMap.put(mParkingLot, gds.listLotLocation(c.getValue())); - return mMap; + public ParkingLot listLotLocation(ParkingChoice c) { + ParkingCoordinate pc = gds.listLotLocation(c.getValue()); + ParkingLot pl = new ParkingLot(); + pl.setLocation(c); + pl.setCoordinate(pc); + return pl; } + } diff --git a/src/com/uncc/gameday/parking/ParkingCoordinate.java b/src/com/uncc/gameday/parking/ParkingCoordinate.java new file mode 100644 index 0000000..3fe8587 --- /dev/null +++ b/src/com/uncc/gameday/parking/ParkingCoordinate.java @@ -0,0 +1,33 @@ +package com.uncc.gameday.parking; + +public class ParkingCoordinate { + private double latitude; + private double longitude; + private String label; + + public double getLatitude() { + return latitude; + } + public void setLatitude(double latitude) { + this.latitude = latitude; + } + public double getLongitude() { + return longitude; + } + public void setLongitude(double longitude) { + this.longitude = longitude; + } + public String getLabel() { + return label; + } + public void setLabel(String label) { + this.label = label; + } + + public ParkingCoordinate(double latitude, double longitude, String label) { + this.latitude = latitude; + this.longitude = longitude; + this.label = label; + } + +} diff --git a/src/com/uncc/gameday/parking/ParkingLocation.java b/src/com/uncc/gameday/parking/ParkingLocation.java deleted file mode 100644 index 28a44c6..0000000 --- a/src/com/uncc/gameday/parking/ParkingLocation.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.uncc.gameday.parking; - -public class ParkingLocation { - - private int latitude; - private int longitude; - private String label; - - public int getLatitude() { - return latitude; - } - public void setLatitude(int latitude) { - this.latitude = latitude; - } - public int getLongitude() { - return longitude; - } - public void setLongitude(int longitude) { - this.longitude = longitude; - } - public String getLabel() { - return label; - } - public void setLabel(String label) { - this.label = label; - } -} diff --git a/src/com/uncc/gameday/parking/ParkingLot.java b/src/com/uncc/gameday/parking/ParkingLot.java index df5b8f9..ecaa8fa 100644 --- a/src/com/uncc/gameday/parking/ParkingLot.java +++ b/src/com/uncc/gameday/parking/ParkingLot.java @@ -4,6 +4,7 @@ public class ParkingLot { private ParkingChoice location; private int filled_pct; + private ParkingCoordinate coordinate; public int getFilledPct() { return filled_pct; @@ -17,5 +18,11 @@ public class ParkingLot { public void setLocation(ParkingChoice location) { this.location = location; } + public ParkingCoordinate getCoordinate() { + return coordinate; + } + public void setCoordinate(ParkingCoordinate coordinate) { + this.coordinate = coordinate; + } } diff --git a/src/com/uncc/gameday/rest/GamedayService.java b/src/com/uncc/gameday/rest/GamedayService.java index f485ef7..23baa61 100644 --- a/src/com/uncc/gameday/rest/GamedayService.java +++ b/src/com/uncc/gameday/rest/GamedayService.java @@ -2,14 +2,17 @@ package com.uncc.gameday.rest; import java.util.List; -import com.uncc.gameday.parking.ParkingLocation; +import retrofit.Callback; +import retrofit.http.Body; +import retrofit.http.GET; +import retrofit.http.POST; +import retrofit.http.Path; + +import com.uncc.gameday.parking.ParkingCoordinate; import com.uncc.gameday.parking.ParkingLot; import com.uncc.gameday.parking.ParkingRating; import com.uncc.gameday.registration.Attendee; -import retrofit.Callback; -import retrofit.http.*; - public interface GamedayService { @GET("/lots/") @@ -22,7 +25,7 @@ public interface GamedayService { void rateLot(@Body ParkingRating p, Callback lot); @GET("/lots/{lot}/") - ParkingLocation listLotLocation(@Path("lot") String lot); + ParkingCoordinate listLotLocation(@Path("lot") String lot); @GET("/register/{id}/") Attendee getUser(@Path("id") int id);