上海交通大学:《Computational Thinking and Approach》教学资源(课件讲稿)Lecture07 OBJECT ORIENTED DEVELOPMENT Class and Object

上游充通大 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

上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Circle The move method will change the value of center to reflect the new position of the circle. All objects are said to be an instance of some class.The class of an object determines which attributes the object will have. A class is a description of what its instances will know and do. 6
Circle • The move method will change the value of center to reflect the new position of the circle. • All objects are said to be an instance of some class. The class of an object determines which attributes the object will have. • A class is a description of what its instances will know and do. 6

上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Circle New objects are created from a class by invoking a constructor.You can think of the class itself as a sort of factory for stamping out new instances. 。( Consider making a new circle object: mycircle Circle(Point (0,0),20) circle,the name of the class,is used to invoke the constructor. 7
Circle • New objects are created from a class by invoking a constructor. You can think of the class itself as a sort of factory for stamping out new instances. • Consider making a new circle object: myCircle = Circle(Point(0,0),20) • Circle, the name of the class, is used to invoke the constructor. 7

上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Circle myCircle Circle(Point(0,0),20) This statement creates a new circle instance and stores a reference to it in the variable mycircle. The parameters to the constructor are used to initialize some of the instance variables (center and radius)inside mycircle. 8
Circle myCircle = Circle(Point(0,0), 20) • This statement creates a new Circle instance and stores a reference to it in the variable myCircle. • The parameters to the constructor are used to initialize some of the instance variables (center and radius) inside myCircle. 8

上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Circle myCircle Circle(Point (0,0),20) Once the instance has been created,it can be manipulated by calling on its methods: myCircle.draw(win) mycircle.move (dx,dy) 9
Circle myCircle = Circle(Point(0,0), 20) • Once the instance has been created, it can be manipulated by calling on its methods: myCircle.draw(win) myCircle.move(dx,dy) 9

上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Class e Classes are just a way to define new sorts of stuff. - Classes are templates for creating user- defined objects. -Instances represent the concrete items in a program's domain. Classes serve as instance factories. 10
Class • Classes are just a way to define new sorts of stuff. – Classes are templates for creating userdefined objects. – Instances represent the concrete items in a program's domain. – Classes serve as instance factories. 10
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 上海交通大学:《Computational Thinking and Approach》教学资源(课件讲稿)Lecture06 OBJECTS AND GRAPHICS GUI.pdf
- 上海交通大学:《Computational Thinking and Approach》教学资源(课件讲稿)Lecture05 ITERATION Control Structure.pdf
- 上海交通大学:《Computational Thinking and Approach》教学资源(课件讲稿)Lecture04 MODULAR PROGRAMMING Functions.pdf
- 上海交通大学:《Computational Thinking and Approach》教学资源(课件讲稿)Lecture03 CONDITIONALS AND SEQUENCES Strings, lists and file objects.pdf
- 上海交通大学:《Computational Thinking and Approach》教学资源(课件讲稿)Lecture02.pdf
- 上海交通大学:《Computational Thinking and Approach》教学资源(课件讲稿)Lecture01.pdf
- 上海交通大学:《操作系统 Operating System》课程教学资料_往年试卷.pdf
- 上海交通大学:《操作系统 Operating System》课程教学资料_管程.docx
- 上海交通大学:《操作系统 Operating System》课程教学资料(Java)Java学习笔记(JAVA的面向对象编程——课堂笔记).doc
- 上海交通大学:《操作系统 Operating System》课程教学资料(Java)JAVA多线程编程详解(详细操作例子).doc
- 上海交通大学:《操作系统 Operating System》课程教学资料(Java)Java多线程编程.pdf
- 上海交通大学:《操作系统 Operating System》课程教学资料(Java)Java多线程应用实例(制作烟花效果).doc
- 上海交通大学:《操作系统 Operating System》课程教学资料(Java)Java Primer.pdf
- 上海交通大学:《操作系统 Operating System》课程教学资料(JAVA PPT)lec5.ppt
- 上海交通大学:《操作系统 Operating System》课程教学资料(JAVA PPT)lec4.ppt
- 上海交通大学:《操作系统 Operating System》课程教学资料(JAVA PPT)lec3.ppt
- 上海交通大学:《操作系统 Operating System》课程教学资料(JAVA PPT)lec2.ppt
- 上海交通大学:《操作系统 Operating System》课程教学资料(JAVA PPT)lec1.ppt
- 上海交通大学:《操作系统 Operating System》课程教学资料(Java)Java Introduction.docx
- 上海交通大学:《操作系统 Operating System》课程教学资源(课件讲稿)OS-thread.pdf
- 上海交通大学:《Computational Thinking and Approach》教学资源(课件讲稿)Lecture08 DATA COLLECTION Massive data representation and processing.pdf
- 上海交通大学:《Computational Thinking and Approach》教学资源(课件讲稿)Lecture09 SIMULATION AND DESIGN Real-world problem.pdf
- 上海交通大学:《Computational Thinking and Approach》教学资源(课件讲稿)Lecture10 ALGORITHM DESIGN AND ANALYSIS To the Classic.pdf
- 上海交通大学:《Computational Thinking and Approach》教学资源(课件讲稿)Something You Should Know.pdf
- 上海交通大学:《C++程序设计与实践》课程教学资源(学习资料)C++练习(题目).pdf
- 上海交通大学:《C++程序设计与实践》课程教学资源(学习资料)C++练习(答案).pdf
- 上海交通大学:《C++程序设计与实践》课程教学资源(学习资料)基于MFC的对话框程序.pdf
- 上海交通大学:《C++程序设计与实践》课程教学资源(课件讲稿)总复习(共八讲).pdf
- 上海交通大学:《C++程序设计与实践》课程教学资源(讲稿)第1讲 C++语言概述及数据类型(何其昌).pdf
- 上海交通大学:《C++程序设计与实践》课程教学资源(讲稿)第2讲 C++程序的流程控制.pdf
- 上海交通大学:《C++程序设计与实践》课程教学资源(讲稿)第3讲 函数与结构化程序设计.pdf
- 上海交通大学:《C++程序设计与实践》课程教学资源(讲稿)第4讲 数组与结构.pdf
- 上海交通大学:《C++程序设计与实践》课程教学资源(讲稿)第5讲 指针与引用.pdf
- 上海交通大学:《C++程序设计与实践》课程教学资源(讲稿)第6讲 C++类(1/2).pdf
- 上海交通大学:《C++程序设计与实践》课程教学资源(讲稿)第7讲 C++类(2/2).pdf
- 上海交通大学:《C++程序设计与实践》课程教学资源(讲稿)第8讲 Windows应用程序设计.pdf
- 上海交通大学:《C++程序设计与实践》课程教学资源(讲义)方波生成器项目报告书.doc
- 《中文信息学报》:中文组织机构名称与简称的识别.pdf
- 《计算机系统结构》课程教学资源(电子书籍)《Computer Organization and Design》THE HARDWARE / SOFTWARE INTERFACE(DAVID A. PATTERSON JOHN L. HENNESSY,Fourth Edtion,彩色版).pdf
- 《计算机系统结构》课程教学资源(电子书籍)《Computer Systems》A Programmer's Perspective(Randal E. Bryant、David R. O'Hallaron,THIRD EDITION).pdf