上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Recitation Notes_Recitation V

VG101 RECITATION 5 By TAs
VG101 RECITATION 5 By TAs

CONTENTS o How to read Vg101Class.h o Samples about graphics o About assignment 5 o Array
CONTENTS How to read Vg101Class.h Samples about graphics About assignment 5 Array

HOW TO READ VG101CLASS.H o This file defines the following classes: o ConsoleT GwindowsT:represent the graphics window oGObjectT:base class for all geometric classes ·LineT ·TriangleT ·RectangleT ArcT:a circle is an arc with an angle of 360 degrees
HOW TO READ VG101CLASS.H This file defines the following classes: ConsoleT GwindowsT: represent the graphics window GObjectT: base class for all geometric classes LineT TriangleT RectangleT ArcT: a circle is an arc with an angle of 360 degrees

HOW TO READ VG101CLASS.H o RandomT:random numbers and colors o PointT:represent a point using (x,y) o PenT:record the current location and color of the pen o MouseT:detect the click event of the mouse,get mouse current location TextT:set text color,style,font...when printing a message to the graphics window (not console window)
HOW TO READ VG101CLASS.H RandomT: random numbers and colors PointT: represent a point using (x, y) PenT: record the current location and color of the pen MouseT: detect the click event of the mouse, get mouse current location TextT: set text color, style, font… when printing a message to the graphics window (not console window)

HOW TO READ VG101CLASS.H o Let's see what's the general structure of a class definition
HOW TO READ VG101CLASS.H Let’s see what’s the general structure of a class definition

class RectangleT:public GObjectT Base class { PointT llp,urp; Data members Private void drawRect ( member constructor 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 ()freturn llp; double getWidth const; Public double getHeight const; Get Set member 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); Function void draw 0; members void draw (const string clr,const double density =0);
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

HOW TO READ VG101CLASS.H o About constructors Rectangle'T (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); o Note: 1.No return type,function name is just its class name. 2.You should declare an object using one of its constructors:
HOW TO READ VG101CLASS.H About constructors 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); Note: 1. No return type, function name is just its class name. 2. You should declare an object using one of its constructors:

HOW TO READ VG101CLASS.H o If the constructor gives the default value of a parameter,then you don't need to give that parameter. use RectangleT myRecO;/default position,color,fill or RectangleT myRec(1,1,2,3);/default color,fill or RectangleT myRece(1,l,2,3,“red”,0.5); /p1,p2 are two known PointT object or RectangleT myRec(p1,p2);/default color,fill or RectangleT myRec(pl,p2,“green”,0.8);
HOW TO READ VG101CLASS.H If the constructor gives the default value of a parameter, then you don’t need to give that parameter. use RectangleT myRec(); // default position, color, fill or RectangleT myRec(1, 1, 2, 3); // default color, fill or RectangleT myRec(1, 1, 2, 3, “red” , 0.5); // p1, p2 are two known PointT object or RectangleT myRec(p1, p2); // default color, fill or RectangleT myRec(p1, p2, “green” , 0.8);

HOW TO READ VG101CLASS.H o What are useful to us ·Get and Set functions double getWidth 0 const; void setWidth(const double w); Other public functions void draw 0; void draw (const string clr,const double density =0);/overloaded function Note: 1.You can't access private/protected data or use private/protected functions directly. 2.The get set functions offer you access to some private data. 3.Read function comment carefully
HOW TO READ VG101CLASS.H What are useful to us Get and Set functions double getWidth () const; void setWidth (const double w); Other public functions void draw (); void draw (const string clr, const double density = 0); // overloaded function Note: 1. You can’t access private/protected data or use private/protected functions directly. 2. The get & set functions offer you access to some private data. 3. Read function comment carefully

SAMPLES ABOUT GRAPHICS o Draw a line from (2,1)to (5,3)in red #include #ing' usir 日vo1c d): t}
SAMPLES ABOUT GRAPHICS Draw a line from (2,1) to (5,3) in red
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Recitation Notes_Recitation IX.ppt
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Recitation Notes_recitation 13.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Recitation Notes_Recitation 1.ppt
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_vector_string.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_Start with C plusplus.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_Random Number_Graphics.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_programming style guide for C plusplus.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_objects and classes.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_Introduction to Vg101.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_Introduction to Computer and Programming.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_Function.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_files_DataBase Design.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_Expressions and Statements.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_examples on class design.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_Array and its Applications.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_20 Looking Ahead.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_19 Recursion 1.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_16 MATLAB environment short.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_15 Introduction to matlab.pdf
- 上海交通大学:《数据库系统原理 The principle of Database System》教学资源_Chapter 1 Introduction.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Recitation Notes_Recitation VII.ppt
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Recitation Notes_Recitation VIII.ppt
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Recitation Notes_Recitation X.ppt
- 上海交通大学:《微机原理与接口技术》课程教学资源(课件讲稿)第十四章 MCS-51单片机(1/2).pdf
- 上海交通大学:《微机原理与接口技术》课程教学资源(课件讲稿)第十四章 MCS-51单片机(2/2).pdf
- 上海交通大学:《微机原理与接口技术》课程教学资源(课件讲稿)第一章 微机原理与接口技术绪论(朱兰娟).pdf
- 上海交通大学:《微机原理与接口技术》课程教学资源(课件讲稿)第二章 8086系统结构.pdf
- 上海交通大学:《数据库系统原理 The principle of Database System》课程教学资源(课件讲稿)chapter9 SQL in a server environment.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)05年期末习题_Pointer Review Solution.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)05年期末习题_Pointer Review.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)05年期末习题_Practice Final 1.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)05年期末习题_practice Final 2.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)05年期末习题_practice Final 3.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)05年期末习题_Solution for Practice Final 1.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)05年期末习题_Solution for Practice Final 2.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C++语言_I.运算符重载.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C++语言_II.继承与派生.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C++语言_III.多态性.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C++语言_IV.异常处理与模板.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C++语言_V. 流库.pdf