/** * Write a description of class Exam here. * * @author (your name) * @version (a version number or a date) */ public class Exam { // instance variables - replace the example below with your own private int examNumber; private String name; private String day; private int startTime; private int endTime; // default constructor public Exam() { // initialise instance variables } // fully qualified constructor public Exam(int examNumber, String name, String day, int startTime, int endTime) { this.examNumber = examNumber; this.name = name; this.day = day; this.startTime = startTime; this.endTime = endTime; } // partially qualified constructor public Exam(int examNumber, String name) { this(examNumber, name, "Mon", 5, 6); } // copy constructor public Exam( Exam otherExam) { this.examNumber = otherExam.examNumber; this.name = otherExam.name; this.day = otherExam.day; this.startTime = otherExam.startTime; this.endTime = otherExam.endTime; } // set methods public void setExamID( int theID) { examNumber = theID; } public void setCourseID( String theName) { name = theName; } public void setExamTime( int start, int end) { this.startTime = start; this.endTime = end; } public String toString() { return "Exam " + examNumber + " for " + name + " on " + day + " from " + startTime + " until " + endTime; } // Display one of the following types of output: // Between exam 1 and 2 there is no overlap // Between exam 1 and 3 there is overlap // Exams overlap if they are on the same day and // there is overlap between times. public void overlaps( Exam other) { System.out.print("Between exam " + this.examNumber + " and " + other.examNumber + " there is "); // figure out whether or not to print "no" if( !this.day.equals( other.day) || this.startTime < other.startTime && this.startTime > other.endTime && this.endTime < other.startTime && this.endTime > other.endTime && other.startTime < this.startTime && other.startTime > this.endTime && other.endTime < this.startTime && other.endTime > this.endTime ) { System.out.print("no "); } System.out.println("overlap"); } }//end class Exam