OOP 3 Student
OOP 3 Student
Starter activity
or
The associated actions of an object.
Method
e
Every new object created from the
Instance
same blueprint.
2
Terminology
Terminology
OO OOP
Object Orientation: Object Oriented Programming:
“Looking at systems by “A method of programming
classifying them into real which classifies real world
world objects” objects into classes and
encapsulates those objects
attributes and behaviours.”
Terminology
Terminology
Class Object
A type definition of an An instance of a class
object
Terminology
Terminology
Instantiation Method
The process of creating an “A program routine contained within
actual named instance of a an object designed to perform a
particular task on the data within the
class. The instantiated object. A method can broadly be
named copy of the class in thought of as a procedure / function
an object of that class. from more traditional procedural
programming languages.”
Starter activity
6
Class Diagrams
Class Diagram
get_name()
get_species() Attributes and their data types.
get_description() Also called instance variables
set_name(self,name)
C. Create a constructor
diagram.
Task
Create the getters and setters
1.Add getters and setters to your class
Make sure you have one for each of the attributes in the Monster class
Tas
Test your new class
2.Create a new file called main.py
3.Import the class at the top of the new file, like this…
1 from monster import Monster
More Tasks
Use the new getters and setter to do the following:
4.Print the name of the Monster
5.Print the line of dialogue
6.Change the health points to another number
7.Print the new health point total.
Task
Take damage:
Speak
Next lesson
Created a class from scratch Extend our Monster game to add new
subclasses.
Accessed and modified attributes on an
object using getters and setters
1
2