Jorell_Ramos_Sinaga

sir, dk tau ngapo kalo buat class dewek utk battery samo network error jadi improvisasi aku

Nov 19th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. class Handphone:
  2.  
  3. def __init__(self, brand):
  4. self.brand = brand
  5. self.capacity = 100
  6.  
  7. def get_brand(self):
  8. print(f"The brand is {self.brand}")
  9.  
  10. def get_capacity_info(self):
  11. print(f"The capacity is {self.capacity}%")
  12.  
  13.  
  14. class Smartphone(Handphone):
  15. def __init__(self, brand):
  16. super().__init__(brand)
  17. self.capacity = 69
  18. self.network = "4G"
  19.  
  20. def get_capacity_info(self):
  21. print(f"The capacity is {self.capacity}%")
  22.  
  23. def get_network_info(self):
  24. print(f"The network speed right now is {self.network}")
  25.  
  26. my_Nokia = Handphone(brand="Nokia")
  27. my_Nokia.get_brand()
  28. my_Nokia.get_capacity_info()
  29.  
  30. my_Apple = Smartphone(brand="Apple")
  31. my_Apple.get_brand()
  32. my_Apple.get_capacity_info()
  33. my_Apple.get_network_info()
Advertisement
Add Comment
Please, Sign In to add comment