home *** CD-ROM | disk | FTP | other *** search
- /*
- File: TSchedulerExample.h
-
- Contains: Declaration of TReport, a TOperation subclass. TOperation objects
- contain the implementation of the task to be performed. This operation
- is placed in TPriorityScheduler, and TSerialScheduler to be performed
- at a requested time. TReport's operation is to display a grade report
- for a student.
-
- Copyright: © 1993 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #ifndef __TSCHEDULEREXAMPLE__
- #define __TSCHEDULEREXAMPLE__
-
- ///————————————————————————————————————————————————————————————————————————————————————
- /// CONSTANTS
- ///————————————————————————————————————————————————————————————————————————————————————
-
- enum Grade {kNoGrade, kA, kB, kC, kD, kCredit, kF};
-
- ///————————————————————————————————————————————————————————————————————————————————————
- /// TReport
- ///————————————————————————————————————————————————————————————————————————————————————
-
- class TReport : public TOperation {
-
- public:
- TReport(); // Constructor
- virtual ~TReport(); // Destructor
-
- virtual void Process(); // Override
-
- // --- New Methods ---
-
- Grade GetGrade() const;
- void SetGrade(Grade grade);
- char* GetStudent() const;
- void NewStudent(char *name);
-
- private:
- char fStudent[256]; // name of the student
- Grade fGrade; // current grade
- };
-
- ///————————————————————————————————————————————————————————————————————————————————————
- /// TREPORT IMPLEMENTATION
- ///————————————————————————————————————————————————————————————————————————————————————
-
- inline Grade TReport::GetGrade() const
- {
- return fGrade;
- }
-
- inline void TReport::SetGrade(Grade grade)
- {
- fGrade = grade;
- }
-
- inline char* TReport::GetStudent() const
- {
- return fStudent;
- }
-
- inline void TReport::NewStudent(char *name)
- {
- strcpy(fStudent, name );
- }
-
- TReport::TReport()
- {
- *fStudent = 0;
- fGrade = kNoGrade;
- }
-
- TReport::~TReport()
- {
- }
-
- void TReport::Process()
- {
- cout << "Student: " << fStudent << "\t\t Grade: " << (char)('@'+fGrade) << endl;
-
- // delete the TReport so creator doesn't need to keep track of operation.
- delete this;
- }
-
- #endif