Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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,

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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. Run -title: String - notes: String - caloriesBurned: int - minutes: int - distance: double + Run(title: String, notes: String, caloriesBurned: int, minutes: int, distance: double) Bike -title: String - notes: String - caloriesBurned: int - minutes: int - distance: double - location: String + Bike(title: String, notes: String, caloriesBurned int, minutes: int, distance: double, location: String) Swim -title: String - notes: String - caloriesBurned: int - distance: double - laps: int - stroke: String + Swim(title: String, notes: String, caloriesBurned: int, distance: double, laps: int, stroke: String) 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 to String() method may not be the same as the sample, but you should print out each property of the object. R Problems @ Javadoc Declaration Console x RunTest.testToString [JUnit] /Library/Java/JavaVirtu Activity - Run RUN: Gym Running Notes: A short running on the treadmill Calories: 300 Distance: 3.0 miles Minutes: 30 min Create an ActiveDay class that summarizes the activities for a given day. It should contain one object of each of the previously defined activities. ActiveDay - dayOfYear: int -run: Run - bike: Bike - Swim: Swim - [name of 4th type of activity]: [Class of 4th type of activity] + Active Day(dayOf Year: int) + totalCaloriesBurned(): int + totalIntensityMinutes(): int + dailySummary(): String 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: int totalcaloriesBurned(): sums the calories for each activity the user performed during the day. int totalIntensityMinutes (): sums the minutes exercising for each activity of the day. String dailySummary : concatenates the description of each activity 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 and Bike activity on the 20th day. Here is a sample output of each function above: Output of dailySummary() R Problems Javadoc Declaration Console X ActiveDayTest.testDailySummaryPrint [JUnit] /Library Summary of Day 20 ==================== Activity - Run RUN: gym running Notes: a short running on the treadmill Calories: 300 Distance: 3.0 miles Minutes: 30 min Activity Bike BIKE: Outside biking Notes: Weekly biking Calories: 500 Minutes: 120 min Distance: 68.0 miles Location: Mountain Bike 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) R Problems @ Javadoc Declaration Console x Active DayTest.test TotalIntensityMinutesPrint [JUnit) Total Intensity Minutes on Day 20 is 150 Output of totalCalories Burned() Problems @ Javadoc Declaration Console x ActiveDayTest.testTotalCaloriesBurned Print [JUnit] Total Calories Burned on Day 20 is 800 There are at least 8 different constructors in the class Active Day 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 Active Day(int day, Run run) the other fields are set to null

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Is too low a financial leverage good or bad? Why?

Answered: 1 week ago

Question

Describe the factors influencing of performance appraisal.

Answered: 1 week ago