Class Run


public class Run extends Object
Author:
s306639
  • Constructor Summary

    Constructors
    Constructor
    Description
    Run​(LocalDateTime start, LocalDateTime end, double myRunDistance, double myCalories)
    CONSTRUCTOR precondition: instance variables have been declared postcondition: data has been initialized options has been initialized by invoking the appropriate method
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addRun​(User u, Run x)
    Method for adding a specific Run to a person's profile/list Preconditions: User u and Run x are both initialized and hold their respective data Postconditions: Run x is added to the hashmap of user U
    void
    Method for calculating the duration of a run in seconds Preconditions: instance variables are initialized Postconditions: The duration in seconds is printed out into the console
    double
    Getter method for myCalories
    Getter method for myEndRunTime
    double
    Getter method for myRunDistance
    int
    Getter method for myRunDurSec
    Getter for myStartRunTime
    long
    Convert current time from hours, minutes, seconds, into seconds only Preconditions: LocalDateTime t contains the correct time Postconditions: The given time is presented in seconds
    void
    setCalories​(double calories)
    Setter method for myCalories
    void
    setMyRunDistance​(double runDistance)
    Setter method for myRunDistance
    void
    Setter method for myStartRunTime

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Run

      public Run(LocalDateTime start, LocalDateTime end, double myRunDistance, double myCalories)
      CONSTRUCTOR precondition: instance variables have been declared postcondition: data has been initialized options has been initialized by invoking the appropriate method
      Parameters:
      start - , the local start time of a given Run
      end - , the local end time of a given Run
      myRunDistance - , the distance of a given Run
      myCalories - , the amount of calories burnt in a given Run
  • Method Details

    • addRun

      public void addRun(User u, Run x)
      Method for adding a specific Run to a person's profile/list Preconditions: User u and Run x are both initialized and hold their respective data Postconditions: Run x is added to the hashmap of user U
      Parameters:
      u - , an object that contains information about a user
      x - , a specific run
    • calculateRunDurSec

      public void calculateRunDurSec()
      Method for calculating the duration of a run in seconds Preconditions: instance variables are initialized Postconditions: The duration in seconds is printed out into the console
    • getSecondDuration

      public long getSecondDuration(LocalDateTime t)
      Convert current time from hours, minutes, seconds, into seconds only Preconditions: LocalDateTime t contains the correct time Postconditions: The given time is presented in seconds
      Parameters:
      t - , LocalDateTime, the current local time
      Returns:
      long(current time in seconds)
    • getMyRunDurSec

      public int getMyRunDurSec()
      Getter method for myRunDurSec
      Returns:
      int(myRunDurSec)
    • getMyRunDistance

      public double getMyRunDistance()
      Getter method for myRunDistance
      Returns:
      double(myRunDistance)
    • setMyRunDistance

      public void setMyRunDistance(double runDistance)
      Setter method for myRunDistance
      Parameters:
      runDistance - , a double value of the distance of a run
    • getMyStartRunTime

      public LocalDateTime getMyStartRunTime()
      Getter for myStartRunTime
      Returns:
      myStartRuntime, a LocalDateTime of the start time of a run
    • setMyStartRunTime

      public void setMyStartRunTime(LocalDateTime startRunTime)
      Setter method for myStartRunTime
      Parameters:
      startRunTime - , a LocalDateTime value of the starting time
    • getMyEndRunTime

      public LocalDateTime getMyEndRunTime()
      Getter method for myEndRunTime
      Returns:
      LocalDateTime(the end time of a run)
    • getCalories

      public double getCalories()
      Getter method for myCalories
      Returns:
      myCalories(the amount of calories burnt in a run)
    • setCalories

      public void setCalories(double calories)
      Setter method for myCalories
      Parameters:
      caloriee - (the amount of calories burnt in a run)