The fourth programming project involves writing a program to test the relationships between time intervals. The...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The fourth programming project involves writing a program to test the relationships between time intervals. The program should contain four classes. The first class should be a generic class Interval defined for any type that implements the Comparable interface. Objects of this type have a start and end of the generic type parameter that defines the start and end of the interval. The class should be immutable, so it should have no setter methods. At a minimum, it should contain the following public methods: ● ● A constructor that accepts the start and end of an interval and constructs an Interval object ● A method within that is supplied an object of the generic type parameter and returns whether that object is inside the interval, including the endpoints A method subinterval that is passed an interval as a parameter and returns whether the interval parameter is a subinterval, completely within, the interval on which the method is invoked A method overlaps that is passed an interval as a parameter and returns whether the interval parameter overlaps the interval on which the method is invoked The second class Time should contain two integer instance variables that represent the hours and minutes and one additional variable for the meridian, AM or PM. The class should implement the Comparable interface and should be immutable, so it should have no setter methods. At a minimum, it should contain the following public methods: A constructor that accepts the hours and minutes as integers and the meridian as a string and constructs a Time object A constructor that accepts a string representation of a time in the format HH:MM AM and constructs a Time object A method compare To that compares two times and returns what is required of all such methods that implement the Comparable interface A method tostring that returns the string representation of the time in the format HH:MM AM When either constructor is called, several checks need to be made on the input. For both constructors, a check is needed to ensure that the hours and minutes are within range and that the meridian is AM or PM. For the constructor that accepts the string representation, additional checks are needed to ensure that the hours and minutes are numeric values. Should any check fail, an exception InvalidTime should be thrown that includes the reason. The third class is the exception class InvalidTime that implements a checked exception. It should have an instance variable of type String that saves the message and the following method: A constructor that accepts the message as a string and constructs an InvalidTime object The fourth class Project 4 should implement a GUI interface that contains two buttons. The first button CompareIntervals should compare the two intervals and output one of the following messages depending upon how the intervals compare: Interval 1 is a sub-interval of interval 2 Interval 2 is a sub-interval of interval 1 The intervals overlap The intervals are disjoint Shown below is an example of the output when the CompareIntervals button is clicked: Time Interval Checker Time Interval 1 Time Interval 2 Time to Check The intervals overlap Start Time 10:30 AM 11:05 AM Compare Intervals Check Time End Time 12:30 PM 1:00 PM X The second button CheckTime should check whether the time is within the intervals and output one of the following messages depending upon which intervals it is within: Both intervals contains the time HH:MM AM Only interval 1 contains the time HH:MM AM Only interval 2 contains the time HH:MM AM Neither interval contains the time HH:MM AM Shown below is an example of the output when the CheckTime button is clicked: Time Interval Checker Time Interval 1 Time Interval 2 Time to Check Start Time 10:30 AM 11:05 AM Compare Intervals 12:50 PM Check Time Only interval 2 contains the time 12:50 PM End Time 12:30 PM 1:00 PM X The fourth programming project involves writing a program to test the relationships between time intervals. The program should contain four classes. The first class should be a generic class Interval defined for any type that implements the Comparable interface. Objects of this type have a start and end of the generic type parameter that defines the start and end of the interval. The class should be immutable, so it should have no setter methods. At a minimum, it should contain the following public methods: ● ● A constructor that accepts the start and end of an interval and constructs an Interval object ● A method within that is supplied an object of the generic type parameter and returns whether that object is inside the interval, including the endpoints A method subinterval that is passed an interval as a parameter and returns whether the interval parameter is a subinterval, completely within, the interval on which the method is invoked A method overlaps that is passed an interval as a parameter and returns whether the interval parameter overlaps the interval on which the method is invoked The second class Time should contain two integer instance variables that represent the hours and minutes and one additional variable for the meridian, AM or PM. The class should implement the Comparable interface and should be immutable, so it should have no setter methods. At a minimum, it should contain the following public methods: A constructor that accepts the hours and minutes as integers and the meridian as a string and constructs a Time object A constructor that accepts a string representation of a time in the format HH:MM AM and constructs a Time object A method compare To that compares two times and returns what is required of all such methods that implement the Comparable interface A method tostring that returns the string representation of the time in the format HH:MM AM When either constructor is called, several checks need to be made on the input. For both constructors, a check is needed to ensure that the hours and minutes are within range and that the meridian is AM or PM. For the constructor that accepts the string representation, additional checks are needed to ensure that the hours and minutes are numeric values. Should any check fail, an exception InvalidTime should be thrown that includes the reason. The third class is the exception class InvalidTime that implements a checked exception. It should have an instance variable of type String that saves the message and the following method: A constructor that accepts the message as a string and constructs an InvalidTime object The fourth class Project 4 should implement a GUI interface that contains two buttons. The first button CompareIntervals should compare the two intervals and output one of the following messages depending upon how the intervals compare: Interval 1 is a sub-interval of interval 2 Interval 2 is a sub-interval of interval 1 The intervals overlap The intervals are disjoint Shown below is an example of the output when the CompareIntervals button is clicked: Time Interval Checker Time Interval 1 Time Interval 2 Time to Check The intervals overlap Start Time 10:30 AM 11:05 AM Compare Intervals Check Time End Time 12:30 PM 1:00 PM X The second button CheckTime should check whether the time is within the intervals and output one of the following messages depending upon which intervals it is within: Both intervals contains the time HH:MM AM Only interval 1 contains the time HH:MM AM Only interval 2 contains the time HH:MM AM Neither interval contains the time HH:MM AM Shown below is an example of the output when the CheckTime button is clicked: Time Interval Checker Time Interval 1 Time Interval 2 Time to Check Start Time 10:30 AM 11:05 AM Compare Intervals 12:50 PM Check Time Only interval 2 contains the time 12:50 PM End Time 12:30 PM 1:00 PM X
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
The second programming project involves writing a program that examines a file of polynomials and determines whether the polynomials in that file are in strictly ascending order using two different...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Which message does the following application print? A. Hello! B. Goodbye! C. See you again! D. It does not compile because of line g1. E. It does not compile because of line g2. F. None of the above....
-
Refer to Exercise 56. Suppose that the person drinks a cup of coffee at 7 a.m. and then drinks a cup of coffee at the end of each hour until 7 a.m. the next day. Refer to Exercise 56, After caffeine...
-
Thomas can invest $10,000 by purchasing a one-year T-bill for $9,775, or he can place the $10,000 in a twelve-month CD paying 2.5%. Which investment will provide a higher return? In addition to...
-
White Mountain Corporation (WMC) sells computer components. It is a publicly traded corporation. William serves as WMCs Chief Executive Officer (CEO). William owns 15 percent of WMCs outstanding...
-
In its income statement for the year ended December 31, 2017, Anhad Company reported the following condensed data. Instructions (a) Prepare a multiple-step income statement. (b) Prepare a single-step...
-
All work must be shown on every facet of the solution. This includes a timeline with cashflows, timing and rates clearly laid out and formulas (in pure form, not in the calculator or excel form). A...
-
Which series has the highest beta. BraveNewCoin Liquid Index for Bitcoin 1D BNC Trading Brave Ne Yellow Green Blue Orange
-
Referring to the "Standards of Ethical Behavior for Practitioners of Management Accounting and Financial Management", which of the preceding items ( a-c ) are acceptable to use? Which are...
-
What extent do you think it is appropriate for central banks to compensate for inaction by the legislative and executive branches? What do you think are the normative implications for democracy in...
-
Regarding the Darden Case - Ferrari: the 2015 IPO What is your estimate of enterprise value for Ferrari? What is your estimate of the value of the firm's equity? What is your estimate of the value...
-
For the system given in the figure, u(t) voltage is applied to the solenoid which is modeled as a system consists of a resistive and an inductive element. Solenoid generates a force u(t) which is a...
-
A product earns an annual gross revenues of $90,000, the variable cost is $60. The fixed costs are $30,000 and the product is sell for $90. The quantity of product sold las year was 1,000. What is...
-
(c) (10 pts) Suppose that the fund manager just shorted another portfolio worth of $10 million with a beta of 1.2, what position in the futures should the fund manager take now to make the combined...
-
A cylindrical wedge is the solid cut from a cylinder by a tilted plane passing through a diameter of the base. Apply Cavalieris Principle to find the volume of such a wedge if its height is 2r, where...
-
Compare and contrast licensing and subcontracting.
-
Suppose you want the average(3,6) function to return an int average of the two int arguments when it is called in one file, and you want it to return a double average of the two int arguments when it...
-
Write a template function max5() that takes as its argument an array of five items of type T and returns the largest item in the array. (Because the size is fixed, it can be hard-coded into the loop...
-
Declare an array of five ints and initialize it to the first five odd positive integers.
-
(a) The longitudinal data set "v4c" is in the vertical format; transform it into the horizontal format. (b) Transform the data set you obtained in part (a) back into the vertical format.
-
Plot the mean/SD of HIV knowledge of adolescent girls at baseline and three months post treatment stratified by treatment for the Sexual Health study.
-
Prove (9.31) . = BE (GS;S; G) BT, B = (B), B-T (9.31)
Study smarter with the SolutionInn App