上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Computational Thinking and Approach Lecture 7 Dr.Jialiang LU Jialiang.lu@situ.edu.cn
Computational Thinking and Approach Lecture 7 Dr. Jialiang LU Jialiang.lu@sjtu.edu.cn
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Class and Object OBJECT ORIENTED DEVELOPMENT
OBJECT ORIENTED DEVELOPMENT Class and Object
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Review of Objects Using objects is a techniques for structuring the data that our programs use. o So far,our programs have made use of objects created from pre-defined class such as circle. An object was defined as an active data type that knows stuff and can do stuff. More precisely,an object consists of: 1.A collection of related information. 2.A set of operations to manipulate that information. 3
Review of Objects • Using objects is a techniques for structuring the data that our programs use. • So far, our programs have made use of objects created from pre-defined class such as Circle. • An object was defined as an active data type that knows stuff and can do stuff. • More precisely, an object consists of: 1. A collection of related information. 2. A set of operations to manipulate that information. 3
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Review of Objects The information is stored inside the object in instance variables. The operations,called methods,are functions that "live"inside the object. Collectively,the instance variables and methods are called the attributes of an object. 4
Review of Objects • The information is stored inside the object in instance variables. • The operations, called methods, are functions that “live” inside the object. • Collectively, the instance variables and methods are called the attributes of an object. 4
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Circle A circle object will have instance variables such as center,which remembers the center point of the circle,and radius,which stores the length of the circle's radius. The draw method examines the center and radius to decide which pixels in a window should be colored. 5
Circle • A Circle object will have instance variables such as center, which remembers the center point of the circle, and radius, which stores the length of the circle’s radius. • The draw method examines the center and radius to decide which pixels in a window should be colored. 5