diff --git a/Seminar 7/problem-in-class/Computer.py b/Seminar 7/problem-in-class/Computer.py new file mode 100644 index 0000000..1895f13 --- /dev/null +++ b/Seminar 7/problem-in-class/Computer.py @@ -0,0 +1,16 @@ +class Computer: + def __init__(self, cpu, memory, storage): + self.__cpu = cpu + self.__memory = memory + self.__storage = storage + + @property + def _memory(self): + return self.__memory + + @_memory.setter + def _memory(self, value): + self.__memory = value + + def __str__(self) -> str: + return f"CPUs: {self.__cpu}; Memory: {self.__memory}; Storage: {self.__storage}; " diff --git a/Seminar 7/problem-in-class/GamingLaptop.py b/Seminar 7/problem-in-class/GamingLaptop.py new file mode 100644 index 0000000..f73d95c --- /dev/null +++ b/Seminar 7/problem-in-class/GamingLaptop.py @@ -0,0 +1,8 @@ +from Laptop import Laptop + +class GamingLaptop(Laptop): + def __init__(self, cpu, memory, storage): + Laptop.__init__(self, cpu, memory, storage, 5) + + def playExtremeGames(): + print("Playing some super cool games.") \ No newline at end of file diff --git a/Seminar 7/problem-in-class/Laptop.py b/Seminar 7/problem-in-class/Laptop.py new file mode 100644 index 0000000..b2e8e53 --- /dev/null +++ b/Seminar 7/problem-in-class/Laptop.py @@ -0,0 +1,27 @@ +from Computer import Computer + +class Laptop(Computer): + pass + def __init__(self, cpu, memory, storage, gpu): + Computer.__init__(self, cpu, memory, storage) + self.__gpu = gpu + + @property + def memory(self): + return self._memory + + @memory.setter + def memory(self, value): + self._memory = value + + def startPlayingGames(self, game): + if(self.__gpu < 2): + print("You can't play games on this laptop.") + else: + print(f"Playing {game}") + + def startDesigning(self): + if(self.__gpu < 1): + print("You can't use this laptop for design.") + else: + print("Designing") \ No newline at end of file diff --git a/Seminar 7/problem-in-class/Smartphone.py b/Seminar 7/problem-in-class/Smartphone.py new file mode 100644 index 0000000..2f009ed --- /dev/null +++ b/Seminar 7/problem-in-class/Smartphone.py @@ -0,0 +1,18 @@ +from Computer import Computer + +class Smartphone(Computer): + pass + def __init__(self, cpu, memory, storage, cellular, phoneNumber): + Computer.__init__(self, cpu, memory, storage) + self.__cellular = cellular + self.__phoneNumber = phoneNumber + + + def receivePhoneCall(self): + print(f"{self.__phoneNumber} is receiving a call.") + + def makePhoneCall(self, to_number): + print(f"{self.__phoneNumber} will call {to_number}") + + def __str__(self) -> str: + return super().__str__() + f"Cellular: {self.__cellular}; Phone number: {self.__phoneNumber}" \ No newline at end of file diff --git a/Seminar 7/problem-in-class/main.py b/Seminar 7/problem-in-class/main.py new file mode 100644 index 0000000..3502919 --- /dev/null +++ b/Seminar 7/problem-in-class/main.py @@ -0,0 +1,18 @@ +from Laptop import Laptop +from Smartphone import Smartphone +from GamingLaptop import GamingLaptop + +def main(): + print('starting main') + bad_laptop = Laptop(2.4, 16, 512, 0.1) + glaptop = GamingLaptop(4, 16, 1024) + sp = Smartphone(1, 2, 8, 'A1', '0883') + + bad_laptop.startPlayingGames('CS') + glaptop.startPlayingGames('CS') + sp.makePhoneCall("testing") + + print(bad_laptop) + +if __name__ == "__main__": + main() \ No newline at end of file