-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance.py
More file actions
40 lines (30 loc) · 808 Bytes
/
inheritance.py
File metadata and controls
40 lines (30 loc) · 808 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
37
38
39
40
class Boat():
#tonnage = 0
#isDocked = True
#name = ""
def __init__(self,tonnage,isDocked,name):
self.tonnage = tonnage
self.isDocked = isDocked
self.name = name
def dock(self):
if self.isDocked == True :
print "The Boat is already docked"
else :
self.isDocked = False
print "The boat has been undocked"
def undock(self):
if self.isDocked == False :
print "The boat is already undocked"
else :
self.isDocked = False
print "The boat has been undocked"
def print_boat(self):
print "tonnage of boat is " , self.tonnage
print "name of the boat is" , self.name
print "Dock Status of Boat is " , self.isDocked
b = Boat(100,False,"Titanic")
b.print_boat()
# Submarine is a subclass of Boat
class Submarine(Boat):
def submerge(self):
print ("submerge")