Question
Talk Scheduling Imagine you are a conference organizer and you are tasked with scheduling the largest possible subset from a set of talks all in
Talk Scheduling
Imagine you are a conference organizer and you are tasked with scheduling the largest possible subset from a set of talks all in the same room. Each talk in the set has a given start time and end time. These times cannot change. No talks that have times that overlap can be scheduled in the same room. For the sake of this assignment assume that one talk can begin instantly upon completion of the previous talk. Consider the example below with three talks in the set:
Talks:
Fred Flinstone 9:00AM-11AM
Barney Rubble 10:30AM-4PM
Bam Bam Rubble 1PM-1:15PM
The optimal schedule (the one that schedules the most talks) in this example would be to schedule Freds talk and Bam Bams talk. Note: Optimal does NOT mean the room is used for the longest time, it means the greatest possible number of talks are scheduled.
This Assignment Step 1: Come up with an algorithm that will lead to scheduling the greatest number of talks. Step 2: Implement your algorithm in Java using the design outline below.
Included is a file containing a list of 50 talks along with their start and end times. I used a 24 hour time format to make this a little easier. Your application must read a file in this format and schedule the maximium number of talks that can be scheduled in a single room. To do this write the following two classes:
Talk.java- This class is used to model a talk and may be used to provide the title and/or speaker for a talk along with the start and stop times of the talk. This class should implement the Comparable interface.
Scheduler.java - This class will serve as a repository for static methods that you will use to schedule the talks.
Included is a test class, ScheduleTest.java. Your code must work with our tester.
ScheduleTest.java
/* Your code must work with test class.
Do not alter this class.
*/
import java.util.ArrayList;
import java.io.*;
public class ScheduleTest{
public static void main(String[] args){
// First, use a command line argument to speicify the f
// name of the file containing the talks.
// Then write a static method makeTalks that returns
// an ArrayList of talks. This method must handle any exceptions.
if (args.length>0)
{
try
{
ArrayList
// Next, pass the ArrayList of talks to the staic method
// scheduleTalks to schedule the maximum number of talks in
// the ArrayList.
ArrayList
// Finally, print the list of scheduled talks. Notice this requires a
// toString method in the Talk class. You will have to provide one.
for (Talk talk:scheduledTalks){
System.out.println(talk);
}
}
catch(IOException e)
{
System.out.println("There is a problem with the file you specified");
}
}
else
{
System.out.println("You must specify a file name at the command line");
}
}
}
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