added car() class
This commit is contained in:
parent
b8c1a3abc9
commit
6829b0457a
@ -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!")
|
||||
|
||||
5
python/PCC-python3/Chapter-06/newcar.py
Normal file
5
python/PCC-python3/Chapter-06/newcar.py
Normal file
@ -0,0 +1,5 @@
|
||||
from car import car
|
||||
|
||||
myCar = car()
|
||||
|
||||
myCar.showOffCar()
|
||||
Loading…
x
Reference in New Issue
Block a user