Create the java program

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Create the java program 

Define a class named TimeSpan. A TímeSpan object stores a span of time in hours
and minutes (for example, the time span between 8:00am and 10:30am is 2 hours, 30
minutes). Each TimeSpan object should have the following public methods:
• new TimeSpan (hours, minutes)
Constructs a TimeSpan object storing the given time span of hours and minutes.
• getHours ()
Returns the number of hours in this time span.
• getMinutes )
Returns the number of minutes in this time span, between 0 and 59.
• add (hours, minutes)
Adds the given amount of time to the span. For example, (2 hours, 15 min) + (1
hour, 45 min) = (4 hours). Assume that the parameters are valid: the hours are
non-negative, and the minutes are between 0 and 59.
%3D
• add (timespan)
Adds the given amount of time (stored as a time span) to the current time span.
• getTotalHours()
Returns the total time in this time span as the real number of hours, such as 9,75
for (9 hours, 45 min).
• toString ()
Returns a string representation of the time span of hours and minutes, such as
"28h46m".
The minutes should always be reported as being in the range of 0 to 59. That means
that you may have to "carry" 60 minutes into a full hour.
Transcribed Image Text:Define a class named TimeSpan. A TímeSpan object stores a span of time in hours and minutes (for example, the time span between 8:00am and 10:30am is 2 hours, 30 minutes). Each TimeSpan object should have the following public methods: • new TimeSpan (hours, minutes) Constructs a TimeSpan object storing the given time span of hours and minutes. • getHours () Returns the number of hours in this time span. • getMinutes ) Returns the number of minutes in this time span, between 0 and 59. • add (hours, minutes) Adds the given amount of time to the span. For example, (2 hours, 15 min) + (1 hour, 45 min) = (4 hours). Assume that the parameters are valid: the hours are non-negative, and the minutes are between 0 and 59. %3D • add (timespan) Adds the given amount of time (stored as a time span) to the current time span. • getTotalHours() Returns the total time in this time span as the real number of hours, such as 9,75 for (9 hours, 45 min). • toString () Returns a string representation of the time span of hours and minutes, such as "28h46m". The minutes should always be reported as being in the range of 0 to 59. That means that you may have to "carry" 60 minutes into a full hour.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY