Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started