fitness tracker
Topics Covered
Objects
Classes
Methods and properties
Method overloading and overriding
Unit testing
Description
We are going to build the first stage of what will become the final project. The idea is to create a fitness tracker application that allows the user to track and view their fitness activities. For this first stage, we are going to build and test some basic classes that we will need in the next steps of this project.
Create an Eclipse project named FitnessTracker. For example, abc123_FitnessTracker.
1. Implement the following classes as represented in the class diagrams. Methods and constructors are explained below.
You will define 4 types of activities: Run, Bike, Swim and the fourth activity is of your choice. Note that the getter/setter methods for all properties are not included in the UML diagram.
2. Override each of the toString() methods to format and output each type of activity. You should print out each property of the object.
Suppose that you have a running activity in the gym. You may create an instance of Run class and print out the running activity details in the terminal window. Here is one possible sample output from the toString() method of the Run class. Please note that the output format of your toString() method may not be the same as the sample, but you should print out each property of the object.
INFSCI 0017: Project 1 Description(Fitness Tracker) Page 2
3. Create an ActiveDay class that summarizes the activities for a given day. It should contain one object of each of the previously defined activities.
Note that the getter/setter methods for all properties are not included in the UML diagram. Also, only one constructor method is included here and you can add different constructors as illustrated.
Note: The integer variable dayOfYear is the numeric representation of the day of the year, starting with January 1 as 1 and December 31 as 365 (assuming it is not a leap year).
Methods in the class ActiveDay:
inttotalCaloriesBurned():sumsthecaloriesforeachactivitytheuser
performed during the day.
inttotalIntensityMinutes():sumstheminutesexercisingforeach
activity of the day.
StringdailySummary():concatenatesthedescriptionofeachactivity
performed during the day. Remember that a day does not have to contain every activity, so if a particular activity is null, then you should not output anything.
Suppose that a user has a Run a nd Bike activity on the 20th day. Here is a sample output of each function above:
Output of dailySummary()
Note that your summary format is not required as same as above. You can design by yourself, but all the properties of a class should be displayed.
Output of totalIntensityMinutes()
Output of totalCaloriesBurned()
There are at least 8 different constructors in the class ActiveDay setting different parts of an active day. All parts that are not passed in the constructor should be set to null. For example, in the constructor ActiveDay(int day, Run run) the other fields are set to null:
Bike bike = null; Swim swim = null; Other other = null;
ActiveDay(dayOfYear: int, run: Run, bike: Bike, swim: Swim, other: Other)
– Represents a day where the user ran, biked, swam and completed your self-defined activity.
ActiveDay(dayOfYear: int, run: Run, bike: Bike, swim: Swim)
– Represents a day where the user ran, biked and swam.
ActiveDay(dayOfYear: int, run: Run, bike: Bike)
– Represents a day where the user ran and biked.
ActiveDay(dayOfYear: int, run: Run)
– Represents a day where the user ran.
ActiveDay(dayOfYear: int, bike: Bike)
– Represents a day where the user biked.
ActiveDay(dayOfYear: int, swim: Swim)
– Represents a day where the user swam.
ActiveDay(dayOfYear: int, other: Other)
– Represents a day where the user performed your self-defined activity.
4. Add getters and setters for all properties in all classes. Getters and setters are not included in the diagram, as they are assumed.
5. Create a class ActiveDayTest which uses Junit to test your functionality. You should include a method that tests each of the methods – totalCaloriesBurned(), totalIntensityMinutes() and dailySummary().
Hint: use the assertEquals() method to test the output of each method.
6. Add comments. Add a comment just above each class definition (top of the file, but after imports and package lines) including your name, Pitt ID and a brief description of each class. Look at this example showing the JavaDoc format:
/**
* Defines a running activity * Author: Jane Doe jan123
*
*/
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.
![](https://collepals.com/wp-content/plugins/posts-import/files/order-now-with-paypal.png)