Added sample files for day 2 and 3

This commit is contained in:
cheezedoodle2
2023-03-31 12:03:53 -07:00
parent 8f30f2b39b
commit 81a2c615bc
8 changed files with 123 additions and 0 deletions
+24
View File
@@ -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)