-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInner_Class.py
More file actions
36 lines (25 loc) · 825 Bytes
/
Inner_Class.py
File metadata and controls
36 lines (25 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Inner Class
class alien :
# Constructor
def __init__(self, height, color) :
self.height = height
self.color = color
# Method
def show(self) :
print(self.height, self.color)
# Inner Class
class spaceship :
# Inner Class Constructor
def __init__(self,shape) :
self.shape = shape
# Inner Class Method
def show(self) :
print(self.shape)
alien1 = alien(5, "blue") # Object of Class alien
alien2 = alien(6, "white") # Object of Class alien
alien1.show()
alien2.show()
alien1ship = alien1.spaceship("round") # Object of Class spaceship
alien1ship.show()
alien2ship = alien2.spaceship("triangle") # Object of Class spaceship
alien2ship.show()