HW TRACKING Summary Now for something a little different wi
*******HW TRACKING******
Summary
Now for something a little different – with a great upcoming snow season, a lot of people will be heading to the mountains for snow sports such as skiing and snowboarding. Ski resorts have found that people generally loves statistics – how fast were they going? Which route did they take? What’s the total distance they traveled? Vertical elevation covered? While these kinds of data are typically captured in an app and the data stored in the Cloud, let’s pretend for a moment that you are writing a simple program to keep track of some statistics for a user.
Skills Expected
All the skills from previous Assignment(s)
Try/Catch Exceptions*
Multi-Dimensional Array*
Assignment Description
You will write two Class objects and a main program (i.e. you will submit three .java files).
Path
Patron
Note: All properties MUST be private.Getters and Setters should be implemented as appropriate.
Class Design: Path
The Path class is intended to be an abstract and simplified representation of a user’s path down the mountain.
For simplicity, let’s assume a few things:
A patron can trigger a “checkpoint” where time and elevation is recorded.
A path must have a starting and an ending point (translation: A path has at least two checkpoints for start and end, but could be more).
A path can have at most 10 checkpoints.
Class Properties
Checkpoints (two-dimensional array to capture time and elevation).
o Must be able to store up to 10 checkpoints.
Class Invariant
Must have at least two but no more than 10 checkpoints.
Time must be between 1000 (10 AM) and 2100 (9 PM) – inclusive.
Elevation must be between 2100 and 7700 (in feet) – inclusive.
Time must be increasing in subsequent elements (can’t go back in time).
Elevation must decrease in subsequent elements (assuming ski/ride down the mountain).
Class Components
A constructor that sets the first two checkpoints (enforce invariants).
A public method to add a checkpoint (enforce invariants here).
A public method to return the total vertical distance traveled.
A public method to return the total time spent on the path.
A public method to return the average speed for the path (what’s the unit?).
A toString() method.
Class Design: Patron
The Patron class is intended to be an abstract and simplified representation of a patron (user).
Class Properties
Nickname (String)
Paths (Array of Path objects – various paths this patron took down the mountain)
Class Invariant
Nickname must not be empty
Class Components
A constructor that sets the initial nickname.
A public method that allows a patron to add a new path.
A public method that return the total vertical distance traveled across all paths.
A public method that return the total time spent across all paths.
A public method that return the average speed across all paths.
A toString() method.
Main Program
The main program (e.g. “TrackingApp”) is to provide a user interface for adding new paths, checkpoints and obtain statistics. It should allow at minimum the following:
Initializing a patron
Changing a patron’s nickname
Adding a new path
Adding a new checkpoint to a path
Viewing the list of paths
Viewing the list of checkpoints for a given path
Viewing the various statistics for the patron
Viewing the various statistics for a given path
Additionally, the main program should:
Respect the various Class invariants.
Ask the user for new data if the user gives bad data.
o May assume that user will at least give the proper data type.
Grading Criteria (30 points total)
Path class object (9 points total)
o [3 points] Implements all required properties
o [3 points] All invariants properly enforced
o [3 points] Required class components properly implemented
Patron class object (9 points total)
o [3 points] Implements all required properties
o [3 points] All invariants properly enforced
o [3 points] Required class components properly implemented
Main Program (8 points total)
o [1 point] Initialize a patron
o [1 point] Change a patron nickname
o [3 points] Add new path
o [2 points] View summary of paths
o [1 point] View patron statistics
[1 point] Proper resizing of array or message indicating array is full (as appropriate)
[1 point] Method JavaDoc: description, @param, @return
[1 Point] Descriptive variable names
[1 Point] Appropriate class header comment block
Solution
There are many details that are not well described. I have mentioned some in comments and these question require more than 2 hours if one try to assume missing details and proceeds according. So I solved it according to whatever details are provided
________________________________________________________________________________
__________________________________________________________________________________
Patron.java
________________________________________________________________________________
Main.java
__________________________________________________________________________________
Sample Output
Please enter patron\'s nickname: rahul
1. Change patron\'s nickname
2. Add a new path
3. Add a new check point to a path
4. View list of paths
5. View list of check points for a path
6. View statistics for the patron
7. View statistics for a path
8. Exit the System
Please enter one of above options(just S.No.): 1
Please enter patron\'s new nickname: Rahul
Please enter one of above options(just S.No.): 4
Please enter one of above options(just S.No.): 2
Time of starting checkpoint: 900
Time of starting checkpoint: 1200
Elevation starting checkpoint: 2000
Elevation starting checkpoint: 2300
Time of ending checkpoint: 1100
Time of ending checkpoint: 1250
Elevation ending checkpoint: 2400
Elevation starting checkpoint: 2100
Please enter one of above options(just S.No.): 4
1. Vertical Distance Traveled: 200feet, Time Spent: 50minutes, Average Speed:4.0 feet/min
Please enter one of above options(just S.No.): 6
NickName: Rahul, Total Vertical Distance Traveled: 200feet, Total Time Spent: 50minutes, Average Speed:4.0 feet/min
Please enter one of above options(just S.No.): 8