Question: Need UML diagram, test cases and lessons learned for program below. import java.util. * ; public class Interval > { private final T start; private
Need UML diagram, test cases and lessons learned for program below.
import java.util.;
public class Interval
private final T start;
private final T end;
public IntervalT start, T end
this.start start;
this.end end;
public boolean containsT point
return point.compareTostart && point.compareToend;
public boolean subintervalInterval other
return other.start.compareTostart && other.end.compareToend;
public boolean overlapsInterval other
return start.compareTootherend && end.compareTootherstart;
public class Time implements Comparable
private final int hours;
private final int minutes;
private final String meridian;
public Timeint hours, int minutes, String meridian throws InvalidTime
if hours hours minutes minutes meridian.equalsAM && meridian.equalsPM
throw new InvalidTimeInvalid time input";
this.hours hours;
this.minutes minutes;
this.meridian meridian;
public TimeString timeStr throws InvalidTime
try
String parts timeStr.split:;
if partslength
throw new InvalidTimeInvalid time format";
int hours Integer.parseIntparts;
int minutes;
String meridian;
if partscontainsAM
meridian AM;
minutes Integer.parseIntpartsreplaceAMtrim;
else if partscontainsPM
meridian PM;
minutes Integer.parseIntpartsreplacePMtrim;
else
throw new InvalidTimeInvalid meridian AMPM;
if hours hours minutes minutes
throw new InvalidTimeInvalid time range";
this.hours hours;
this.minutes minutes;
this.meridian meridian;
catch NumberFormatException ArrayIndexOutOfBoundsException e
throw new InvalidTimeInvalid time format";
@Override
public int compareToTime other
int thisTime this.hours this.minutes;
int otherTime other.hours other.minutes;
return Integer.comparethisTime otherTime;
@Override
public String toString
return String.formatd:d s this.hours, this.minutes, this.meridian;
public class InvalidTime extends Exception
public InvalidTimeString message
supermessage;
import javax.swing.;
import java.awt.;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Project
public static void mainString args
SwingUtilities.invokeLater createAndShowGUI;
private static void createAndShowGUI
JFrame frame new JFrameTime Interval Checker";
frame.setDefaultCloseOperationJFrameEXITONCLOSE;
JButton compareButton new JButtonCompare Intervals";
JButton checkTimeButton new JButtonCheck Time";
Implement action listeners for the buttons
compareButton.addActionListenernew ActionListener
@Override
public void actionPerformedActionEvent e
JOptionPane.showMessageDialogframe "Compare Intervals button clicked.";
Add your logic here for comparing intervals
;
checkTimeButton.addActionListenernew ActionListener
@Override
public void actionPerformedActionEvent e
JOptionPane.showMessageDialogframe "Check Time button clicked.";
Add your logic here for checking time
;
JPanel panel new JPanelnew GridLayout;
Add buttons to the panel
panel.addnew JLabel;
panel.addnew JLabel;
panel.addcompareButton;
panel.addcheckTimeButton;
frame.getContentPaneaddBorderLayoutCENTER, panel;
frame.setSize;
frame.setVisibletrue;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
