Programming Assignment 2: C++
Assigned: March 24
Due: April 7
A scheduling problem consists of a collections of jobs, which must
be executed on a processor. In particular, a schedule S is
an assignment of each job to run from a start time to an ending time.
(Assume that jobs cannot be interrrupted.) A schedule is correct
if it satisfies constraints of various kinds.
In one simple variant of the problem, each job J as an associated
J.Length. The ending time of J in a given schedule is equal to
the start time plus the length. The schedule must satisfy the constraint
that no two jobs overlap; that is, for any two jobs J1 and J2, it cannot be
true that the start time of J1 precedes the end time of J2 and the
start time of J2 preceded the end time of J1.
Other features of a job might include a release time with the
associated constraint that the job may not start earlier than the release time;
a due time with the associated constraint that the job may not
end later than the due time; and a set of predecessor jobs with
the constraint that, if J1 is a predecessor of J2, then the end time of J1
cannot be later than the start time of J1.
contains the skeleton of a C++ program that:
- Defines four classes:
- Job has an ID, a length, and a start time.
- ReleaseJob is an extension of Job with a release time.
- DueJob is an extension of Job with a due time.
- PredJob is an extension of Job with a list of predecessors
- Defines a method "check" for each of these, which checks the correctness
of the job.
- For ReleaseJob, DueJob, and PredJob, defines individual checking
methods for their particular constraints.
Defines a global method checkSchedule, which checks a schedule by checking
each job in turn.
- Defines a main method, which creates 4 jobs, assigns them to various
starting times, and checks the correctness of the resulting schedule.
Your job is to complete the code so that it runs correctly.
Note in particular:
- I have deleted the keywords associated with the various "check" methods.
You have to figure out what are the correct keywords here.
- You may not change the code in "checkSchedule" or "main".
- I have given the code of "checkSchedule" to illustrate how to use
lists in C++. The other methods that need to loop through the schedule have
a similar structure.
Code that does not compile gets no more than 1 point out of 10.
Correctly working code gets at least 9 points out of 10. The remaining point
is for elegant coding and adequate commenting.
Code that compile but does not always work correctly get partial credit. Of
course, the methods have to work correctly on examples other than the
particular ones in "main".
Submission Email your C++ source code to Samantha.