diff --git a/src/MaterialManager.py b/src/MaterialManager.py index bdfbaa2..ce4a4e0 100644 --- a/src/MaterialManager.py +++ b/src/MaterialManager.py @@ -7,22 +7,38 @@ def __init__(self, params: list): self.params = params # other configurations - def changeMaterial(self, material) -> bool: + def changeMaterial(self, material) -> bool: returnText = "" + textBaseForValidMaterial = "Material is changed to" match material: case materialType.Titanium: self.carManager.setMaterial(materialType.Titanium) - returnText = "Material is changed to Titanium." + returnText = f"{textBaseForValidMaterial} Titanium." case materialType.Carbon: self.carManager.setMaterial(materialType.Carbon) - returnText = "Material is changed to Carbon." + returnText = f"{textBaseForValidMaterial} Carbon." + + case materialType.AlloyX: + self.carManager.setMaterial(materialType.AlloyX) + returnText = f"{textBaseForValidMaterial} AlloyX." case _: - returnText = "Material seletion is invalid." + returnText = "Material selection is invalid." return self._announceMaterial(returnText) + + + def _announceMaterial(self, text: str) -> bool: - return self.announcer(text) + returnValue = False + try: + returnValue = self.announcer(text) + except: + print("Announcement of material type is failed.") + returnValue = False + finally: + return returnValue + diff --git a/src/Util.py b/src/Util.py index 81ab0ba..5abfeff 100644 --- a/src/Util.py +++ b/src/Util.py @@ -1,3 +1,3 @@ from enum import Enum -materialType = Enum('Titanium', 'Carbon') +materialType = Enum('Titanium', 'Carbon', 'AlloyX')