Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getX(), getId() to Elevator and getElevator ro Passenger (fix issues #6 #19) #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions clients/java1.8_client/client/src/main/java/core/API/Elevator.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
public class Elevator implements MessagesInterface {
private Integer id;
private Double x;
private Double y;
private List<Passenger> passengers;
private Integer state;
Expand Down Expand Up @@ -42,6 +43,10 @@ public String getType() {
return this.type;
}

public Double getX() {
return this.x;
}

public Double getY() {
return this.y;
}
Expand All @@ -60,6 +65,11 @@ public List<JSONObject> getMessages(){

public Elevator(JSONObject elevator) {
id = (int) (long) elevator.get("id");
if (elevator.get("x") instanceof Long) {
x = ((Long) elevator.get("x")).doubleValue();
} else {
x = (double) elevator.get("x");
}
if (elevator.get("y") instanceof Long) {
y = ((Long) elevator.get("y")).doubleValue();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public Boolean hasElevator() {
return this.elevator != null;
}

public Integer getElevator() {
return this.elevator;
}

public List<JSONObject> getMessages() {
return this.messages;
}
Expand Down Expand Up @@ -95,6 +99,7 @@ public Passenger(JSONObject passenger) {
weight = (double) passenger.get("weight");
}
}

public void setElevator(Elevator elevator) {
this.elevator = elevator.getId();
JSONObject jo = new JSONObject();
Expand All @@ -105,5 +110,4 @@ public void setElevator(Elevator elevator) {
jo.put("args", args);
this.messages.add(jo);
}

}