From 6829b0457ab7e693b428abeef65cd65a577f6634 Mon Sep 17 00:00:00 2001 From: Ganome Date: Sun, 30 May 2021 12:37:11 -0600 Subject: [PATCH] added car() class --- python/PCC-python3/Chapter-06/car.py | 41 ++++--------------------- python/PCC-python3/Chapter-06/newcar.py | 5 +++ 2 files changed, 11 insertions(+), 35 deletions(-) create mode 100644 python/PCC-python3/Chapter-06/newcar.py diff --git a/python/PCC-python3/Chapter-06/car.py b/python/PCC-python3/Chapter-06/car.py index 3168591..f6a354c 100644 --- a/python/PCC-python3/Chapter-06/car.py +++ b/python/PCC-python3/Chapter-06/car.py @@ -5,39 +5,10 @@ class car: self.__wheels = 4 self.__windows = 6 self.__doors = 4 + self.__horsepower = 100 + self.__totaled = False + self.__color = "black" + self.__customized = False - -class computer: - def __init__(self): - self.__CPU = 0 - self.__RAM = 0 - self.__STORAGE = 0 - self.__FIREWALL = 0 - self.__AV = 0 - self.__OS = 0 - self.__NETWORK = 0 - - def setCPU(self, speed): - self.__CPU = speed - def setRAM(self, ram): - self.__RAM = ram - def setSTORAGE(self, storage): - self.__STORAGE = storage - def setOS(self, os): - self.__OS = os - def setNETWORK(self, network): - self.__NETWORK = network - - def newComputer(self, cpu, ram, storage, os, network): - self.__CPU = cpu - self.__RAM = ram - self.__STORAGE = storage - self.__OS = os - self.__NETWORK = network - - -myPC = computer() -myPC.setCPU(500) -myPC.setRAM(32) - -print(myPC._computer__CPU, myPC._computer__RAM) + def showOffCar(self): + print(f"My car still has {self.__wheels} wheels\n{self.__windows} windows,\n{self.__doors} doors are attached,\nTotaled out: {self.__totaled},\nWith {self.__horsepower} horsepower!") diff --git a/python/PCC-python3/Chapter-06/newcar.py b/python/PCC-python3/Chapter-06/newcar.py new file mode 100644 index 0000000..9456e46 --- /dev/null +++ b/python/PCC-python3/Chapter-06/newcar.py @@ -0,0 +1,5 @@ +from car import car + +myCar = car() + +myCar.showOffCar() \ No newline at end of file