Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help creating two classes in a java program Skier Class To write this program you will need a class for skiers. Skier should

I need help creating two classes in a java program

Skier Class

To write this program you will need a class for skiers. Skier should should have the following fields:

  • name (String)
  • country (String)
  • starting time (Time)
  • ending time (Time)
  • race time (Time)

Skier should have the following methods:

  • constructor with four parms: name, country, start time, and end time. It should also calculate the amount of time it took the Skier to complete the race.
  • raceTime: returns a Time object and has no parms. It returns the amount of time taken by the Skier in the race.
  • toString
  • compareTo: compare two Skier objects by comparing the race time. The Skier with the smaller race time is the one that's smaller.

Time Class

The Time class will store times using a 24 hour clock: midnight is hour 00, 3am is hour 03, noon is hour 12, 3pm is hour 15, and 11pm is hour 23. When you store hours, minutes and seconds which are less than 10 they will not have a leading zero. When you print them they should have a leading zero. The fields of the Time class are:

  • hour (int) holds the hour in 24 hour time
  • minutes (int) holds the minute
  • seconds (double) holds the second

The Time class has the following methods:

  • default constructor: initialize the Time to 0, which is midnight
  • initializing constructor: parms for the hour, minute, and second
  • toString: format the Time as hh:mm:ss.sss, in 24 hour format; be sure to use two digits if the hour, minutes, or seconds is less than 10
  • equals
  • compareTo: return -1 if the time in this is before (or shorter than) the time in the parm; return 0 if they are the same; return 1 if the time in this is after (or longer than) the time in the parm.
  • minus: parm is a Time; return a new Time object that is the amount of time between this and the parm, assuming that this is after (greater than) the parm. For example, if this is 18:23:45.5 and the parm is 16:30:24.75, then minus returns a Time object that contains 01:53:20.75

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

Students also viewed these Databases questions