subject

Modify the TimeSpan class from Chapter 8 to include a compareTo method that compares time spans by their length. A time span that represents a shorter amount of time is considered to be "less than" one that represents a longer amount of time. For example, a span of 3 hours and 15 minutes is greater than a span of 1 hour and 40 minutes. GIVEN TIMESPAN FILE/** Adapted for CS211 from Building Java Programs, 4th Edition,* by Stuart Reges and Marty Stepp* adapted by James Livingston, Bellevue College Adjunct Instructor*/// Represents a time span of elapsed hours and minutes.// Simple implementation using only total minutes as state. public class TimeSpan {private int totalMinutes;// Constructs a time span with the given interval.// pre: hours >= 0 && minutes >= 0public TimeSpan(int hours, int minutes) {totalMinutes = 0;add(hours, minutes);}// Adds the given interval to this time span.// pre: hours >= 0 && minutes >= 0public void add(int hours, int minutes) {totalMinutes += 60 * hours + minutes;}// Returns a String for this time span such as "6h15m".public String toString() {return (totalMinutes / 60) + "h"+ (totalMinutes % 60) + "m";}}GIVEN TIMESPANMAIN FILE/** TimeSpanClient: a simple test client for the TimeSpan class* Shows creation of an instance object, displaying that object,* adding hours and minutes to that object, and showing the result.*/public class TimeSpanClient {public static void main(String[] args) {int h1 = 13, m1 = 30;TimeSpan t1 = new TimeSpan(h1, m1);System. out. println("New object t1: " + t1); h1 = 3; m1 = 40;System. out. println("Adding " + h1 + " hours, " + m1 + " minutes to t1");t1.add(h1, m1);System. out. println("New t1 state: " + t1);}}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 07:50
Apython programming question: assume s is a string of lower case characters. write a program that prints the number of times the string 'bob' occurs in s. for example, if s = 'azcbobobegghakl', then your program should print number of times bob occurs is: 2
Answers: 3
question
Computers and Technology, 23.06.2019 12:00
From excel to powerpoint, you can copy and paste a. cell ranges and charts, one at a time. b. cell ranges and charts, simultaneously. c. charts only. d. cell ranges only.
Answers: 3
question
Computers and Technology, 24.06.2019 13:20
3. ranga ramasesh is the operations manager for a firm that is trying to decide which one of four countries it should research for possible outsourcing providers. the first step is to select a country based on cultural risk factors, which are critical to eventual business success with the provider. ranga has reviewed outsourcing provider directories and found that the four countries in the table that follows have an ample number of providers from which they can choose. to aid in the country selection step, he has enlisted the aid of a cultural expert, john wang, who has provided ratings of the various criteria in the table. the resulting ratings are on a 1 to 10 scale, where 1 is a low risk and 10 is a high risk. john has also determined six criteria weightins: trust, with a weight of 0.3; quality, with 0.2; religious, with 0.1; individualism, with 0.2; time, with 0.1; and uncertainity, with 0.1. using the factor-rating method, which country should ranga select? why? (2 points)
Answers: 3
question
Computers and Technology, 24.06.2019 14:00
Text or graphics that print at the bottom of every page are called footings footers headers headings
Answers: 1
You know the right answer?
Modify the TimeSpan class from Chapter 8 to include a compareTo method that compares time spans by t...
Questions
question
Computers and Technology, 11.05.2021 17:40
question
Mathematics, 11.05.2021 17:40
question
Mathematics, 11.05.2021 17:40
Questions on the website: 13722362