diff --git a/main.py b/main.py index 1d98040..93a666b 100644 --- a/main.py +++ b/main.py @@ -6,12 +6,26 @@ class Train: self.name = name if name else "#" def __str__(self): return f"Class {self.class_}({self.name})" + def manufacturer(self): + return "" -class C315(Train): - def __init__(self, name): - #Train.__init__(self, 315, name) - super().__init__(315, name) +class BREL(Train): + def __init__(self, class_): + super().__init__(class_, "") + def manufacturer(self): + return "BREL" -c315 = C315("Joe") -print(c315) +class PEP(Train): + def __init__(self, class_): + super().__init__(class_, "PEP") + def manufacturer(self): + return "Unknown" + +#The presendence of definitions is the order in the inheritance bracket +class C315(BREL, PEP): + def __init__(self): + super(BREL,self).__init__(315) + +c315 = C315() +print(c315, c315.manufacturer()) del c315