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:
![The fourth programming project involves writing a program to test the relationships between time intervals.](https://dsd5zvtm8ll6.cloudfront.net/questions/2023/12/6588b95b41937_1703549125853.jpg)
![The fourth class Project 4 should implement a GUI interface that contains two buttons. The first button](https://dsd5zvtm8ll6.cloudfront.net/questions/2023/12/6588b97984a24_1703549156759.jpg)
![Time Interval Checker Time Interval 1 Time Interval 2 Time to Check Start Time 10:30 AM 11:05 AM Compare](https://dsd5zvtm8ll6.cloudfront.net/questions/2023/12/6588b98c36ffa_1703549175602.jpg)
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
-
Types of recruitment In the past, the recruitment process was a reactive one in which companies did not necessarily conduct an analysis of the type of strategy they would use to recruit candidates....
-
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....
-
Three movie critics have each rated a number of current movies on a scale of 1 = poor to 10 = excellent. Given the ratings in file XR14039, use the 0.025 level of significance in comparing the...
-
2 0 of 6 Required information Exercise 13-22A (Algo) Recording events in the general journal, posting to T-accounts, and preparing closing entries LO 13-1, 13-2, 13-3, 13-4 The following information...
-
Compare the results from the a priori algorithm with those of the GRI algorithm. Which algorithm yields a richer set of rules, and why? Which algorithm is probably preferable for this particular data...
-
For each of the following records, indicate the appropriate related file structure: master file, transaction file, reference file, or archive file. a. Customer ledgers b. Purchase orders c. List of...
-
QUESTION 6 Which of the following does NOT explain properly about submission, approval and president veto in the budget process of the U.S.? 1. After submission, policy-makers review budget proposals...
-
Problem Statement: The aim of this case study is to propose a daily capacity level and level of resourcing required for Q2 & Q3 2023. The proposed daily capacity level should achieve the highest...
-
Denton Company manufactures and sells a single product. Cost data for the product are given: \ table [ [ Variable costs per unit:,$ 5
-
What is a transistor, and what are its types?
-
Discuss the emerging role of nanotechnology in electrical engineering, focusing on its applications in enhancing electrical components like batteries, supercapacitors, and sensors.Explore the...
-
1. As resistors are added in parallel to an existing circuit, what happens to the voltage drop measured across each resistor? 2. In the circuit shown on the right, which path (left or right) will...
-
Here are the returns on two stocks. Digital Cheese January +16 February -4 March +6 April +8 May -5 June +4 July -3 August -9 Executive Fruit January +9 February +1 March +7 April +16 May +2 June +7...
-
The following processes constitute the air-standard Diesel cycle: 12: isentropic compression,23: constant-volume energy addition (T and P increase),34: constant-pressure energy addition (v...
-
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.
-
The efficient market hypothesis suggests that it is difficult to outperform the market on a consistent basis. Are there possible exceptions to the hypothesis that concern the valuation of common...
-
How might a Daily Spending Diary result in wiser consumer buying and more saving for the future?
-
Jamie Lee sat down with a salesperson to discuss a new vehicle and its $24,000 purchase price. Jamie Lee has heard that no one really pays the vehicle sticker price. What guidelines may be suggested...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App