// Job.cpp Dave Reed 2/5/05 /////////////////////////////////////////////////////////////////////////////// #include #include #include "Job.h" using namespace std; Job::Job(int id, int arrival, const string & bursts) // Assumes: id is unique, arrival and len >= 0 // Results: constructs a job object, initializes executedSoFar to 0 { jobID = id; jobArrivalTime = arrival; istringstream istr(bursts); int b; while (istr >> b) { jobBursts.push(b); } } int Job::getID() const // Returns: returns ID number of the job { return jobID; } int Job::getArrival() const // Returns: returns arrival time of the job { return jobArrivalTime; } int Job::getRemainingBurst() const // Returns: returns length of the job { return jobBursts.front(); } JobStatus Job::execute() // Assumes: job is not done yet (executedSoFar < length) // Returns: status (OK, IO or DONE) after executing the job for a cycle { jobBursts.front()--; if (jobBursts.front() == 0) { jobBursts.pop(); if (jobBursts.empty()) { return DONE; } else { return IO; } } else { return OK; } }