Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Design and implement classes to perform the required functionalities. These classes are separated from the GUI. Design and implement user - Exercise Trackerfriendly GUI. Design
Design and implement classes to perform the required functionalities. These classes are separated from the GUI.
Design and implement user Exercise Trackerfriendly GUI.
Design and implement classes to handle persistent data sources ie files
In this assignment, we will use many of the concepts we had learned about to design a simple exercise tracker. The exercise tracker will be able to track three different kinds of exercises: runwalk weightlifting, and rock climbing. It will store the data the user enters about each workout and will be able to save it to a file. It will also be able to present it on screen sorted by either data or calories burned.
All kinds of exercises can be described in terms of a name, a comment, the date it took place, and its duration. In addition, runwalk exercises have a distance, weightlifting has an amount lifted, and rock climbing has the height of the wall and number of repetitions. This gives rise to the following hierarchy of classes:
Superclass: Exercise, containing the things that are common to all exercises
Subclasses: RunWalk, WeightLifting, and RockClimbing
Each type of exercise has its rate for burning calories. For this simplified exercise tracker, we will assume the following:
RunWalk: distance in miles divided by duration in minutes, then multiplied by
Weightlifting: total weight lifted in pounds divided by duration in minutes, then multiplied by
Rock climbing: height of wall times number of times scaled divided by duration in minutes, then multiplied by
You must declare the Exercise class to be abstract It will have variables for storing the things that are common to all exercises. It will have get and set functions and constructors. It will use the java.util.Date class to store the date, but it will provide a way to set the data from a String having MMDDYYYY format for convenience. This will require using the SimpleDateFormat class with format MMddyyyy It will have a toString function that will help with writing a tabdelimited description of the exercise to a file. It will have an abstract getType function that, in subclasses, will return the type of the exercise. It will have an abstract getCaloriesBurned function that, in subclasses, will return the calories burned. It will also implement the Comparable interface so that a list of exercises can be sorted by their date.
You must declare the RunWalk, WeightLifting, and RockClimbing subsclasses of Exercise. Each of these will introduce variables for storing the things that are specific to these exercises. They will implement the abstract functions that were introduced in Exercise.
You must declare a class called ExerciseCompareByCalories that implements Comparator. It will override the inherited compare function to compare two Exercise objects by their calorie values. This will make it possible for us to sort the list of exercises by their calories burned.
You must declare a class called ExerciseWriter. It will have static functions for writing a list of exercises in tabdelimited format to the screen or to a file as well as a function called tabulateSummary that will print a table of exercises containing columns for the type, name, date and calories burned for each exercise.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started