PC class

lets the user enter in specific pc parts and their price then calculates the total price of the pc and lets the user see the individual parts.


class PC: def __init__(self, name, CPU, CPUprice, GPU, GPUprice, RAM, RAMprice, case, casePrice, cooler, coolerPrice, motherboard, motherboardPrice, storage, storagePrice, monitor, monitorPrice, PSU, PSUprice): self.name = name self.CPU = [CPU, CPUprice] self.GPU = [GPU, GPUprice] self.RAM = [RAM, RAMprice] self.case = [case, casePrice] self.cooler = [cooler, coolerPrice] self.motherboard = [motherboard, motherboardPrice] self.storage = [storage, storagePrice] self.monitor = [monitor, monitorPrice] self.PSU = [PSU, PSUprice] def printPartList(self): print(self.CPU[0]) print(self.GPU[0]) print(self.RAM[0]) print(self.case[0]) print(self.cooler[0]) print(self.motherboard[0]) print(self.storage[0]) print(self.monitor[0]) print(self.PSU[0]) def printTotalPrice(self): print( "total price: $" + (str(self.CPU[1] + self.GPU[1] + self.RAM[1]+self.case[1]+self.cooler[1]+self.motherboard[1]+self.storage[1]+self.storage[1]+self.PSU[1]))) def printOnePart(self): print("===============================") print("1. CPU") print("2. GPU") print("3. RAM") print("4. Case") print("5. Cooler") print("6. Motherboard") print("7. Storage") print("8. Monitor") print("9. PSU") print("===============================") answer = "y" while answer == "y": selection = int(input("select the number of which part you would like to see")) if (selection == 1): print("CPU:", self.CPU[0], "costs $" + str(self.CPU[1])) elif (selection == 2): print("GPU:", self.GPU[0], "costs $" + str(self.GPU[1])) elif (selection == 3): print("RAM:", self.RAM[0], "costs $" + str(self.RAM[1])) elif (selection == 4): print("Case:", self.case[0], "costs $" + str(self.case[1])) elif (selection == 5): print("Cooler:", self.cooler[0], "costs $" + str(self.cooler[1])) elif (selection == 6): print("Motherboard:", self.motherboard[0], "costs $" + str(self.motherboard[1])) elif (selection == 7): print("Storage:", self.storage[0], "costs $" + str(self.storage[1])) elif (selection == 8): print("Monitor:", self.monitor[0], "costs $" + str(self.monitor[1])) elif (selection == 9): print("PSU:", self.PSU[0], "costs $" + str(self.PSU[1])) else: print("Invalid input!") answer = input("would you like to see another part (y/n)?") mypc=PC("Alans pc","Intel - Core i9-9900K 3.6 GHz 8-Core Processor", 484,"Asus - GeForce RTX 2080 8 GB ROG Strix Gaming OC Video Card",769 , "G.Skill - Trident Z RGB 16 GB (2 x 8 GB) DDR4-3600 Memory", 114, "NZXT H700I",179, "NZXT kraken X62", 139, "MSI - Z390-A PRO ATX LGA1151 Motherboard",129 , "Samsung - 970 Evo 1 TB M.2-2280 Solid State Drive1", 214,"alienware-aw2518hf-245-1920x1080-240hz-monitor-aw2518hf", 389, "Asus - 850 W 80+ Platinum Certified Fully Modular ATX Power Supply" ,209) mypc.printPartList() mypc.printTotalPrice() mypc.printOnePart()
1