-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpewarisan.py
More file actions
43 lines (35 loc) · 821 Bytes
/
Copy pathpewarisan.py
File metadata and controls
43 lines (35 loc) · 821 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
41
42
43
# pewarisan / inheritance
# - siswa
# - guru
# - kepala seekolah
# class Hewan:
# def __init__(self, nama: str) -> None:
# self.nama: str = nama
#
# def makan(self) -> None:
# print(f"{self.nama} sedang makan")
#
# class Kucing(Hewan):
# def __init__(self, nama: str, warna: str) -> None:
# super().__init__(nama)
# self.warna: str = warna
#
# def mengeong(self) -> None:
# print(f"{self.nama} berkata: meong....")
#
#
# kucing = Kucing("james", "putih")
#
# print(kucing.nama)
# print(kucing.warna)
#
# kucing.makan()
# kucing.mengeong()
class Kendaraan:
def bergerak(self) -> None:
print("kendaraan bergerak")
class Mobil(Kendaraan):
def bergerak(self) -> None:
print("mobil bergerak dengan roda")
mobil = Mobil()
mobil.bergerak()