Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

https://www.chegg.com/homework-help/questions-and-answers/classes-public-class-bike-private-string-title-private-string-notes-private-int-caloriesbu-q46182307 Task 1: Create the Activity class. This will be the superclass for Run, Bike, Swim and (all 4 of these classes extend Activity). As

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedhttps://www.chegg.com/homework-help/questions-and-answers/classes-public-class-bike-private-string-title-private-string-notes-private-int-caloriesbu-q46182307

Task 1: Create the Activity class. This will be the superclass for Run, Bike, Swim and (all 4 of these classes extend Activity). As a result, the common methods, properties, getters, and setters previously defined are moved to the Activity class. See the following diagram. Implement the class Activity. Activity - dayOfYear: int -title:String - caloriesBurned: int - minutes: int + Activity(dayOfYear:int, title:String, calories Burned: int, minutes: int) Run Bike Swim Be sure to update the constructors to receive all properties values and to call the super constructor. Override the toString() method in each class that extends Activity in order to return the name of the specific activity. Task 2: Update the Fitness Tracker class In our Fitness Tracker program, we will display the activities by week. Update the Fitness Tracker class to include methods that will help you determine the current date and handle other date-based functionality. You can use the LocalDate class to manage and manipulate dates for the purposes of this project. (Here is a quick tutorial on LocalDate). The code below creates a new LocalDate object and sets the DAY OF YEAR, for the current year. For example, if the variable dayOfYear is equal to 46, the date returned is February 15, 2020. LocalDate today = LocalDate.now().withDayOf Year (dayOfYear); Once you have a LocalDate, you can then determine the DAY OF WEEK for the given date. The method getDayOfWeek () in LocalDate can help you there. today.getDayOfWeek(); //returns SATURDAY Implement the generateDayOfYear() method. This method should generate a random number between 0 and 364. This number will represent the current day of the year. Every time you launch your program, it should select a random day of the year as the current day. The getDaysInCurrentWeek () method will return an integer that represents the number of days in the current week. o Weeks run from Monday - Sunday. If it is Wednesday, then this method should return 3. o Once you have the number of days in the current week, you can use that number plus the current day number to get the active day data from your array. Hint: the current day is your endIndex and endIndex - daysInCurrentWeek is your start index. Task 3: Updates to Active Day Make sure you have a toString method of the ActiveDay class prints out a summary of an active day (or non-active day) accordingly. Task 4: Build the following GUI and interactions The last part of this project brings everything together. You will build the following user interface to bring your code to life. Your UI does not need to look exactly like this, but it should be close and include all of the required elements and functionality. You will need to add additional methods to handle events and other functionality described below. 1. Create the class Fitness TrackerGUI containing all of the graphic components and a Fitness Tracker object. This class will contain your main method. 2. Declare al components (al JLabel, JFrame, JButton, JComboBox, JTextField, etc) as properties in Fitness TrackerGUI. 3. Make sure you declare a Fitness Tracker object as a property of the Fitness TrackerGUI dass 4. Start by building your GUI components, then add event handling. You can use a LayoutManager of your choice. The GUI doesn't need to look exactly like the wireframe above, but it should provide all of the same functionality. 5. The constructor of the class Fitness TrackerGUI should do a. Create the FitnessTracker object, which prompts the user to provide data files for each type of activity. You can use a FileChooser or allow them to enter the exact file location. b. Initialize and place all graphic components c. Display the default data, as defined in #6 below. 6. The main window should: a. Display today's date as any format you want, and also display the day of the year (integer). b. Display the Total Miles for the week and year c. Display the Total Active Minutes for the week and year. d. The default view of this screen should display a summary of activities from today and yesterday. Hint: Use your toString method of Active Day to print each day. This method should provide a summary (totals per day), not each individual activity per day . If you didn't have any activities today or yesterday, your program should display a user-friendly message. e. Provide a way for the user to navigate activities by week. . The Forward/Next button should update the view to display all activities for the next week (given the current week), but not past the current day. . The Previous/Back button should update the view to display all activities for a previous week (given the current week), to the first of the year. . Be sure to display the start and end dates for each week. 1. "Display by Selected Activity Button": Displays all activities of a selected activity type (eg, run, bike, swim, custom) in a text area. Note: Activities past the current day of the year, should not be displayed. g. Allow the user to manually add an activity. The activity needs to be added to memory (e.g. the appropriate ArrayList in the Fitness Tracker class) and written to the text file. Note: If you completed the bonus activity for Project 2, then you just need to add the GUI component for this functionality. BONUS (3 points): Display the user's active day streak. "Congrats, you have b active N days in a row. Note, if the user was not active yesterday, a streak is not possible 8. BONUS(5 points): add a way for the user to view totals per month Task 1: Create the Activity class. This will be the superclass for Run, Bike, Swim and (all 4 of these classes extend Activity). As a result, the common methods, properties, getters, and setters previously defined are moved to the Activity class. See the following diagram. Implement the class Activity. Activity - dayOfYear: int -title:String - caloriesBurned: int - minutes: int + Activity(dayOfYear:int, title:String, calories Burned: int, minutes: int) Run Bike Swim Be sure to update the constructors to receive all properties values and to call the super constructor. Override the toString() method in each class that extends Activity in order to return the name of the specific activity. Task 2: Update the Fitness Tracker class In our Fitness Tracker program, we will display the activities by week. Update the Fitness Tracker class to include methods that will help you determine the current date and handle other date-based functionality. You can use the LocalDate class to manage and manipulate dates for the purposes of this project. (Here is a quick tutorial on LocalDate). The code below creates a new LocalDate object and sets the DAY OF YEAR, for the current year. For example, if the variable dayOfYear is equal to 46, the date returned is February 15, 2020. LocalDate today = LocalDate.now().withDayOf Year (dayOfYear); Once you have a LocalDate, you can then determine the DAY OF WEEK for the given date. The method getDayOfWeek () in LocalDate can help you there. today.getDayOfWeek(); //returns SATURDAY Implement the generateDayOfYear() method. This method should generate a random number between 0 and 364. This number will represent the current day of the year. Every time you launch your program, it should select a random day of the year as the current day. The getDaysInCurrentWeek () method will return an integer that represents the number of days in the current week. o Weeks run from Monday - Sunday. If it is Wednesday, then this method should return 3. o Once you have the number of days in the current week, you can use that number plus the current day number to get the active day data from your array. Hint: the current day is your endIndex and endIndex - daysInCurrentWeek is your start index. Task 3: Updates to Active Day Make sure you have a toString method of the ActiveDay class prints out a summary of an active day (or non-active day) accordingly. Task 4: Build the following GUI and interactions The last part of this project brings everything together. You will build the following user interface to bring your code to life. Your UI does not need to look exactly like this, but it should be close and include all of the required elements and functionality. You will need to add additional methods to handle events and other functionality described below. 1. Create the class Fitness TrackerGUI containing all of the graphic components and a Fitness Tracker object. This class will contain your main method. 2. Declare al components (al JLabel, JFrame, JButton, JComboBox, JTextField, etc) as properties in Fitness TrackerGUI. 3. Make sure you declare a Fitness Tracker object as a property of the Fitness TrackerGUI dass 4. Start by building your GUI components, then add event handling. You can use a LayoutManager of your choice. The GUI doesn't need to look exactly like the wireframe above, but it should provide all of the same functionality. 5. The constructor of the class Fitness TrackerGUI should do a. Create the FitnessTracker object, which prompts the user to provide data files for each type of activity. You can use a FileChooser or allow them to enter the exact file location. b. Initialize and place all graphic components c. Display the default data, as defined in #6 below. 6. The main window should: a. Display today's date as any format you want, and also display the day of the year (integer). b. Display the Total Miles for the week and year c. Display the Total Active Minutes for the week and year. d. The default view of this screen should display a summary of activities from today and yesterday. Hint: Use your toString method of Active Day to print each day. This method should provide a summary (totals per day), not each individual activity per day . If you didn't have any activities today or yesterday, your program should display a user-friendly message. e. Provide a way for the user to navigate activities by week. . The Forward/Next button should update the view to display all activities for the next week (given the current week), but not past the current day. . The Previous/Back button should update the view to display all activities for a previous week (given the current week), to the first of the year. . Be sure to display the start and end dates for each week. 1. "Display by Selected Activity Button": Displays all activities of a selected activity type (eg, run, bike, swim, custom) in a text area. Note: Activities past the current day of the year, should not be displayed. g. Allow the user to manually add an activity. The activity needs to be added to memory (e.g. the appropriate ArrayList in the Fitness Tracker class) and written to the text file. Note: If you completed the bonus activity for Project 2, then you just need to add the GUI component for this functionality. BONUS (3 points): Display the user's active day streak. "Congrats, you have b active N days in a row. Note, if the user was not active yesterday, a streak is not possible 8. BONUS(5 points): add a way for the user to view totals per month

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

Issues In Management Accounting

Authors: Trevor Hopper, Robert W. Scapens, Deryl Northcott

3rd Edition

0273702572, 978-0273702573

More Books

Students also viewed these Accounting questions