Class Race


  • public class Race
    extends java.lang.Object
    Represents a Race.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private com.badlogic.gdx.graphics.Texture barrier
      The separator between each lane.
      private java.util.ArrayList<ComputerBoat> computerBoats
      The list of boats in the race, not including the player.
      private int length
      The length of the race.
      private Boat player
      The players boat.
      private FinishLine theFinish
      The finish line.
      private float timer
      The timer for the race.
    • Constructor Summary

      Constructors 
      Constructor Description
      Race​(int raceLength, BoatType boatChosen, int round)
      Creates a new race of a specified length.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void dispose()  
      boolean equals​(java.lang.Object obj)  
      java.util.Set<java.lang.Float> findDuplicates​(java.util.ArrayList<java.lang.Float> list)
      Find any duplicates in an arraylist of floats.
      void getLeaderBoard​(DragonBoatRace game)
      Generate the leaderboard from the race that just occurred and then show the next round screen.
      Boat getPlayer()
      Get the players boat.
      void render​(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
      Render the boats in the race and the player boat.
      void restore()  
      void save()  
      void update​(float deltaTime, DragonBoatRace game)
      Update the race in respects to the amount of time passed since the last frame.
      • Methods inherited from class java.lang.Object

        clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • length

        private final int length
        The length of the race.
      • computerBoats

        private final java.util.ArrayList<ComputerBoat> computerBoats
        The list of boats in the race, not including the player.
      • player

        private final Boat player
        The players boat.
      • theFinish

        private final FinishLine theFinish
        The finish line.
      • barrier

        private final com.badlogic.gdx.graphics.Texture barrier
        The separator between each lane.
      • timer

        private float timer
        The timer for the race.
    • Constructor Detail

      • Race

        public Race​(int raceLength,
                    BoatType boatChosen,
                    int round)
        Creates a new race of a specified length.
        Parameters:
        raceLength - The length of the race.
        boatChosen - The BoatType that the player chose.
        round - The current round of the race.
    • Method Detail

      • update

        public void update​(float deltaTime,
                           DragonBoatRace game)
        Update the race in respects to the amount of time passed since the last frame.
        Parameters:
        deltaTime - The time since the last frame.
        game - The instance of the game.
      • render

        public void render​(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
        Render the boats in the race and the player boat.
        Parameters:
        batch - The SpriteBatch to be added to.
      • getLeaderBoard

        public void getLeaderBoard​(DragonBoatRace game)
        Generate the leaderboard from the race that just occurred and then show the next round screen.
        Parameters:
        game - The instance of the game.
      • findDuplicates

        public java.util.Set<java.lang.Float> findDuplicates​(java.util.ArrayList<java.lang.Float> list)
        Find any duplicates in an arraylist of floats.
        Parameters:
        list - An ArrayList of floats to be combed through.
        Returns:
        An Set of type float containing unique values.
      • getPlayer

        public Boat getPlayer()
        Get the players boat.
        Returns:
        A Boat representing the players boat.
      • dispose

        public void dispose()
      • restore

        public void restore()
      • save

        public void save()
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object