// File: Thing.h // // One file that contains the class definitions of // Thing, Wall and Goal. // // You must not alter this file. // #ifndef THING_H #define THING_H class Car ; class RaceCourse ; //------------------------------------------------------------------- class Thing { public : // Default constructor Thing() ; // Alternate constructor // Assigns the row and position of the Thing // Thing(unsigned int row, unsigned int col) ; // Destructor // Thing has no dynamically allocated data, but derived class might. // virtual ~Thing() ; // What happens when a Car bounces off current Thing. // Mostly interesting in the derived classes. // virtual void encounter (Car *ptr) ; // Report row and column of this Thing's position // unsigned int GetRow() const ; unsigned int GetCol() const ; // DrawMe() returns a character that can be used by // PrettyPrintCourse and others to print this Thing. // For example, a Wall object returns '#'. // virtual char DrawMe() const =0 ; // Stores a RaceCourse pointer in Rptr. // When a Thing is added to a RaceCourse, the RaceCourse // should use SetRaceCoursePtr() to store a pointer // to the RaceCourse in the Thing. // void SetRaceCoursePtr(RaceCourse *ptr) ; protected : unsigned int m_row ; unsigned int m_col ; RaceCourse *Rptr ; } ; //------------------------------------------------------------------- // A Wall object represents an obstacle in the race course. // Cars are not penalized for bumping into a Wall. class Wall : public Thing { public: Wall() ; Wall(unsigned int row, unsigned int col) ; char DrawMe() const ; } ; //------------------------------------------------------------------- // A Car that bumps into a Goal wins the race. class Goal : public Thing { public: Goal() ; Goal(unsigned int row, unsigned int col) ; char DrawMe() const ; void encounter (Car *ptr) ; Car *GetWinner() const ; protected: Car *winner ; } ; #endif