mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Implemented leg class and added legs to the race
- #implement
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package seng302;
|
||||
|
||||
public class Leg {
|
||||
private int heading;
|
||||
private int distance;
|
||||
private String startLabel;
|
||||
private boolean isFinishingLeg;
|
||||
|
||||
public Leg(int heading, int distance, String label){
|
||||
this.heading = heading;
|
||||
this.distance = distance;
|
||||
this.startLabel = label;
|
||||
this.isFinishingLeg = false;
|
||||
}
|
||||
|
||||
public void setHeading(int heading){
|
||||
this.heading = heading;
|
||||
}
|
||||
|
||||
public int getHeading(){
|
||||
return this.heading;
|
||||
}
|
||||
|
||||
public void setDistance(int distance){
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public int getDistance(){
|
||||
return this.distance;
|
||||
}
|
||||
|
||||
public void setLabel(String label){
|
||||
this.startLabel = label;
|
||||
}
|
||||
|
||||
public String getLabel(){
|
||||
return this.startLabel;
|
||||
}
|
||||
|
||||
public void setFinishingLeg(boolean isFinishingLeg){
|
||||
this.isFinishingLeg = isFinishingLeg;
|
||||
}
|
||||
|
||||
public boolean getIsFinishingLeg(){
|
||||
return this.isFinishingLeg;
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,12 @@ import java.util.List;
|
||||
|
||||
public class Race {
|
||||
private ArrayList<Boat> boats;
|
||||
private ArrayList<Leg> legs;
|
||||
private int numberOfBoats = 0;
|
||||
|
||||
public Race(){
|
||||
boats = new ArrayList<Boat>();
|
||||
legs = new ArrayList<Leg>();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -71,7 +73,6 @@ public class Race {
|
||||
|
||||
/*
|
||||
Prints the list of boats competing in the race
|
||||
|
||||
*/
|
||||
public void displayStartingBoats(){
|
||||
int numberOfBoats = this.getNumberOfBoats();
|
||||
@@ -83,4 +84,14 @@ public class Race {
|
||||
System.out.println(boats[i].getTeamName());
|
||||
}
|
||||
}
|
||||
|
||||
public void addLeg(Leg leg){
|
||||
this.legs.add(leg);
|
||||
}
|
||||
|
||||
public void printLegs(){
|
||||
for (Leg leg : this.legs.toArray(new Leg[legs.size()])){
|
||||
System.out.println(leg.getLabel());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user