diff --git a/src/main/java/seng302/App.java b/src/main/java/seng302/App.java index 5af4e232..9c5f2b15 100644 --- a/src/main/java/seng302/App.java +++ b/src/main/java/seng302/App.java @@ -1,9 +1,32 @@ package seng302; +import java.util.ArrayList; + public class App { + /* + Displays the order in which the boats finished + + @param race The current race + */ + public static void displayFinishingOrder(Race race){ + int numberOfBoats = race.getNumberOfBoats(); + Boat[] boats = race.getFinishedBoats(); + + System.out.println("--- Finishing Order ---"); + + for (int i = 0; i < numberOfBoats; i++) { + System.out.println("#" + Integer.toString(i+1) + " - " + boats[i].getTeamName()); + } + } + + + + public static void main( String[] args ) { - System.out.println(""); + Race race = new Race(); + + displayFinishingOrder(race); } } \ No newline at end of file diff --git a/src/main/java/seng302/Race.java b/src/main/java/seng302/Race.java index 06fb7901..32ab5c56 100644 --- a/src/main/java/seng302/Race.java +++ b/src/main/java/seng302/Race.java @@ -8,6 +8,7 @@ import java.util.List; public class Race { private ArrayList boats; + private int numberOfBoats = 0; public Race(){ boats = new ArrayList(); @@ -15,15 +16,16 @@ public class Race { /* Add a boat to the race - @param boat the boat to add + @param boat, the boat to add */ public void addBoat(Boat boat){ boats.add(boat); + numberOfBoats += 1; } /* Returns a list of boats in the order that they - finished the race (0 is first) + finished the race (position 0 is first) @returns a list of boats */ @@ -34,4 +36,13 @@ public class Race { return boats.toArray(new Boat[boats.size()]); } + + /* + Returns the number of boats in the race + + @returns the number of boats in the race + */ + public int getNumberOfBoats(){ + return numberOfBoats; + } } \ No newline at end of file