CSI 260 - JadenGil/Jaden-Tech-Journal GitHub Wiki
"""DESCRIPTION OF THE MODULE GOES HERE
Author: Jaden Gilmond Class: CSI-260-01 Assignment: Week 11 Lab Due Date: April 10th, 2023 11:59 PM
Certification of Authenticity: I certify that this is entirely my own work, except where I have given fully-documented references to the work of others. I understand the definition and consequences of plagiarism and acknowledge that the assessor of this assignment may, for the purpose of assessing this assignment:
- Reproduce this assignment and provide a copy to another member of academic
- staff; and/or Communicate a copy of this assignment to a plagiarism checking
- service (which may then retain a copy of this assignment on its database for
- the purpose of future plagiarism checking) """
from functools import total_ordering
@total_ordering class Temperature: """Represents a temperature."""
def __str__(self):
return f'{self.celsius}°C'
def __repr__(self):
return f'Temperature({self.celsius})'
def __lt__(self, other):
if isinstance(other, Temperature):
return self.celsius < other.celsius
else:
return self.celsius < other
def __eq__(self, other):
if isinstance(other, Temperature):
return self.celsius == other.celsius
else:
return self.celsius == other
def __add__(self, other):
if isinstance(other, Temperature):
return Temperature(self.celsius + other.celsius)
else:
return Temperature(self.celsius + other)
def __radd__(self, other):
if isinstance(other, Temperature):
return Temperature(self.celsius + other.celsius)
else:
return Temperature(self.celsius + other)
def __sub__(self, other):
if isinstance(other, Temperature):
return Temperature(self.celsius - other.celsius)
else:
return Temperature(self.celsius - other)
def __rsub__(self, other):
if isinstance(other, Temperature):
return Temperature(other.celsius - self.celsius)
else:
return Temperature(other - self.celsius)
def __iadd__(self, other):
if isinstance(other, Temperature):
self.celsius += other.celsius
else:
self.celsius += other
return self
def __isub__(self, other):
if isinstance(other, Temperature):
self.celsius -= other.celsius
else:
self.celsius -= other
return self
def __hash__(self):
return hash(str(self))
def __init__(self, degrees=0):
self.celsius = degrees