Added sample files for day 2 and 3
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
class Temperature:
|
||||
temperature: float
|
||||
|
||||
def __init__(self, temperature):
|
||||
self.temperature = temperature
|
||||
|
||||
def __add__(self, operand):
|
||||
if operand.__class__ != '__main__.Temperature':
|
||||
raise ValueError(f"That's not a temperature object! It's a {operand.__class__}!")
|
||||
self.temperature += operand.temperature
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.temperature=}"
|
||||
def insert_object(self, obj):
|
||||
self.temperature += obj.temperature
|
||||
|
||||
if __name__ == "__main__":
|
||||
oven = Temperature(180.0)
|
||||
chicken = Temperature(5.0)
|
||||
print(f"{chicken + oven=}")
|
||||
oven.insert_object(chicken)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user