1 / 4

OOP and Graphics

OOP and Graphics. Object Oriented Programming. The ‘classic’ point of view of a programmer was that the program instructions were the active part, the data just sat there and was manipulated. A new paradigm became popular in the 80’s: OOP

naida-giles
Télécharger la présentation

OOP and Graphics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OOP and Graphics

  2. Object Oriented Programming • The ‘classic’ point of view of a programmer was that the program instructions were the active part, the data just sat there and was manipulated. • A new paradigm became popular in the 80’s: OOP • The idea is that programs should be considered as interactions of objects. An object was a structure that “knew things” (i.e. had data values) and “did things” (i.e. had operations to do on the data) (There’s quite a bit more to the paradigm than that, but that will do for now.)

  3. Objects in Graphics • The graphics library is set up as a collection of object templates • Point, Circle, Rectangle, Line and so on • These templates are called “classes”. They are the “pattern” for what a particular object should be. • Example: a Point class would have data about the position of the point (x, y) and functions that could do things with that information • You call a function called a “constructor” to make a new object from the class. Constructor methods are almost always the same name as the name of the class. (Objects are also called “instances”.)

  4. Objects in Graphics • Once you have an object constructed, it has a name. You can give the object commands by calling the methods (functions) that it knows about. • Example: p = Point(200, 300) # p is now an object from class Point p.draw(win) p.move(0, 5) • Note the syntax: “dot notation”. The statement or expression starts with the object name, followed by a dot, then the name of the method and its arguments, if any.

More Related