|
@@ -0,0 +1,83 @@
|
|
|
|
+
|
|
|
|
+class Thing:
|
|
|
|
+ pass
|
|
|
|
+
|
|
|
|
+class Thing2:
|
|
|
|
+ letters = 'abc'
|
|
|
|
+
|
|
|
|
+class Thing3:
|
|
|
|
+ letters = 'xyz'
|
|
|
|
+
|
|
|
|
+class Element:
|
|
|
|
+ def __init__(self, name, symbol, number) -> None:
|
|
|
|
+ self.__name = name
|
|
|
|
+ self.__symbol = symbol
|
|
|
|
+ self.__number = number
|
|
|
|
+
|
|
|
|
+ def get_name(self):
|
|
|
|
+ return self.__name
|
|
|
|
+
|
|
|
|
+ def get_symbol(self):
|
|
|
|
+ return self.__symbol
|
|
|
|
+
|
|
|
|
+ def get_number(self):
|
|
|
|
+ return self.__number
|
|
|
|
+
|
|
|
|
+ def __str__(self):
|
|
|
|
+ return f'Name: {self.__name}, Symbol: {self.__symbol}, Number: {self.__number}'
|
|
|
|
+
|
|
|
|
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
+
|
|
|
|
+class Bear:
|
|
|
|
+ def eats(self):
|
|
|
|
+ return 'berries'
|
|
|
|
+
|
|
|
|
+class Rabbit:
|
|
|
|
+ def eats(self):
|
|
|
|
+ return 'clover'
|
|
|
|
+
|
|
|
|
+class Octothorpe:
|
|
|
|
+ def eats(self):
|
|
|
|
+ return 'campers'
|
|
|
|
+
|
|
|
|
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
+class Laser:
|
|
|
|
+ def does(self):
|
|
|
|
+ return 'disintegrate'
|
|
|
|
+
|
|
|
|
+class Claw:
|
|
|
|
+ def does(self):
|
|
|
|
+ return 'crush'
|
|
|
|
+
|
|
|
|
+class SmartPhone:
|
|
|
|
+ def does(self):
|
|
|
|
+ return 'ring'
|
|
|
|
+
|
|
|
|
+class Robot:
|
|
|
|
+ laser = Laser()
|
|
|
|
+ claw = Claw()
|
|
|
|
+ phone = SmartPhone()
|
|
|
|
+
|
|
|
|
+ def does(self):
|
|
|
|
+ print('Laser:', self.laser.does())
|
|
|
|
+ print('Claw:', self.claw.does())
|
|
|
|
+ print('SmartPhone:', self.phone.does())
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def ex1():
|
|
|
|
+ foo = Thing()
|
|
|
|
+ # print(Thing)
|
|
|
|
+ # print(foo)
|
|
|
|
+ # print(Thing2.letters)
|
|
|
|
+ # print(Thing3.letters)
|
|
|
|
+
|
|
|
|
+ elem1 = Element('Hydrogen', 'H', '1')
|
|
|
|
+ my_dict = {'name': 'Hydrogen', 'symbol': 'H', 'number': 1}
|
|
|
|
+ elem2 = Element(my_dict['name'], my_dict['symbol'], my_dict['number'])
|
|
|
|
+ # elem2.dump()
|
|
|
|
+ print(elem2)
|
|
|
|
+
|
|
|
|
+ robot = Robot()
|
|
|
|
+ robot.does()
|
|
|
|
+
|
|
|
|
+ex1()
|