CSE 163
Object-Oriented Programming I�
Suh Young Choi�
🎶 Listening to: Orbitron
💬 Before Class: If you could pick a language to be instantly fluent in but could never visit any country where it’s officially recognized, what would you pick?
Checking in
Weekly Tokens
Project/Portfolio
2
Announcements
3
Last Time + This Time
Last Time
This Time
4
Objects
5
State:
self.name
Behavior:
.thwip()
State:
self.name
Behavior:
.thwip()
Objects
6
spider_man = SpiderMan(‘Peter Parker’)
amazing_sm = SpiderMan(‘Peter Parker’)
State:
self.name
Behavior:
.thwip()
State:
self.name
Behavior:
.thwip()
Objects
7
spider_man = SpiderMan(‘Peter Parker’)
amazing_sm = SpiderMan(‘Peter Parker’)
spider_man
State:
self.name
State:
‘Peter Parker’
Behavior:
.thwip()
amazing_sm
State:
self.name
State:
‘Peter Parker’
Behavior:
.thwip()
Objects
8
State:
self.name
State:
self.name
State:
‘Peter Parker’
Behavior:
.thwip()
spider_man = SpiderMan(‘Peter Parker’)
amazing_sm = SpiderMan(‘Peter Parker’)
spider_man.thwip()
spider_man
State:
‘Peter Parker’
Behavior:
.thwip()
amazing_sm
References
9
State:
self.name
State:
self.name
State:
‘Peter Parker’
Behavior:
.thwip()
spider_man = SpiderMan(‘Peter Parker’)
amazing_sm = spider_man
spider_man.thwip()
spider_man
State:
‘Peter Parker’
Behavior:
.thwip()
amazing_sm
References
10
State:
‘Peter Parker’
Behavior:
.thwip()
spider_man = SpiderMan(‘Peter Parker’)
amazing_sm = spider_man
spider_man.thwip()
spider_man
amazing_sm
= SpiderMan(‘Peter Parker’)
Multiple references �be like
11
Class
Here is a full class
12
class SpiderFolk:
def __init__(self, name: str) -> None:
self.name: str = name
def thwip(self) -> None:
print(self.name + ‘: Thwip!')
A class definition
An initializer that sets fields (state)
A method (behavior)
Spiderfolking�Around
13
s1 = SpiderFolk(‘Cindy’)
s2 = SpiderFolk(‘Jessica’)
s3 = s1
s1.thwip()
s2.thwip()
s3.thwip()
s1
name:
‘Cindy'
s2
name: ‘Jessica'
s3
# Cindy: Thwip!
# Jessica: Thwip!
# Cindy: Thwip!
Note to Self
14
class SpiderFolk:
def __init__(self, name):
self.name = name
def thwip(self):
print(self.name + ‘: Thwip!')
s1 = SpiderFolk(‘Cindy')
s2 = SpiderFolk(‘Jessica')
s3 = s1
s1.thwip()
s2.thwip()
s3.thwip()
Group Work:
Best Practices
When you first working with this group:
Tips:
15
Next Time + Before Next Time
Before Next Time
Next Time
16