VG101 RECITATION 8 By TAs
VG101 RECITATION 8 By TAs
CONTENTS o Brief review of class o Strategy for assignment 9 o Questions about assignment 7,8
CONTENTS Brief review of class Strategy for assignment 9 Questions about assignment 7, 8
BRIEF REVIEW OF CLASS o In header file: ·Base class · Constructors Private/protected/public member Data/function member ·Accessors/utators o In cpp file: Implementation of class functions
BRIEF REVIEW OF CLASS In header file: Base class Constructors Private/protected/public member Data/ function member Accessors/ Mutators In cpp file: Implementation of class functions
class RectangleT:public GObjectT { Base class PointT llp,urp;∠ Data members Private void drawRect ( member public: constructor RectangleT(const double x0=0,const double y0=0, const double x1=0,const double y1=0, const string clr ="Blue",const double fill=0); RectangleT(const PointT &p0,const PointT &p1, const string clr ="Blue",const double fill=0); const PointT &getLocation (return llp;) double getWidth const; double getHeight const; Public double getArea const; Get Set member void setLocation (const double x,const double y); void setLocation(const PointT p); void setWidth (const double w); void setHeight (const double h); void draw 0; Function void draw (const string clr,const double density =0); members
class RectangleT : public GObjectT { PointT llp, urp; void drawRect (); public: RectangleT (const double x0 = 0, const double y0 = 0, const double x1 = 0, const double y1 = 0, const string clr = "Blue", const double fill = 0); RectangleT (const PointT &p0, const PointT &p1, const string clr = "Blue", const double fill = 0); const PointT &getLocation () {return llp;} double getWidth () const; double getHeight () const; double getArea () const; void setLocation (const double x, const double y); void setLocation (const PointT p); void setWidth (const double w); void setHeight (const double h); void draw (); void draw (const string clr, const double density = 0); }; Base class Private member Public member constructor Get & Set Data members Function members
BRIEF REVIEW OF CLASS o Base class Base class will be constructed first ·∥BallT is a derived class from ArcT ·/∥A ball is an arc of360 degree BallT (double r=0):ArcT (r,0,360,"Blue",1); o Constructors Always define a default constructor(suggested) One and only one of the constructors must be called
BRIEF REVIEW OF CLASS Base class Base class will be constructed first // BallT is a derived class from ArcT // A ball is an arc of 360 degree BallT (double r = 0) : ArcT (r, 0, 360, "Blue" , 1) {}; Constructors Always define a default constructor (suggested) One and only one of the constructors must be called