ClassSchedule.java /**
A class has a title, time and room
*/
public class ClassSchedule
{
private String title;
private String days;
private String startTime;
private String endTime;
private String room;
/**
Constructs a class with title, day, time and room.
*/
public ClassSchedule(String classTitle, String meetingDays, String aStartTime, String aEndTime, String classRoom)
{
title = classTitle;
days = meetingDays;
startTime = aStartTime;
endTime = aEndTime;
room = classRoom;
}
/**
Gets the title.
@return the title
*/
public String getTitle()
{
return title;
}
/**
Gets the time in the form "days start time-end time"
@return the time
*/
public String getTime()
{
String time = days + " " + startTime + "-" + endTime;
return time;
}
/**
Gets the room.
@return the room
*/
public String getRoom()
{
return room;
}
/**
Sets the days.
@param meetingDays the new meeting days
*/
public void setDays(String meetingDays)
{
// your work here
}
/**
Sets the start time.
@param aStartTime the new start time
*/
public /* your work here */ setStartTime(/* your work here */)
{
// your work here
}
/**
Sets the end time.
@param anEndTime the new end time
*/
// your work here
}
Use the following file:
ClassScheduleTester.java
public class ClassScheduleTester
{
public static void main(String[] args)
{
ClassSchedule class1 = new ClassSchedule("Intro to Java","MWF","9:00", "9:50","Turing 101");
class1.setStartTime("11:00");
class1.setEndTime("11:50");
System.out.println(class1.getTitle() +
" meets " + class1.getTime() + " in " + class1.getRoom() );
System.out.println("Expected: Intro to Java meets MWF 11:00-11:50 in Turing 101");
ClassSchedule class2 = new ClassSchedule("Operating Systems","TT","12:30","1:45","Turing 307");
class2.setDays("MW");
class2.setStartTime("2:00");
class2.setEndTime("3:15");
System.out.println(class2.getTitle() +
" meets " + class2.getTime() + " in " + class2.getRoom() );
System.out.println("Expected: Operating Systems meets MW 2:00-3:15 in Turing 307");
}
}