static void Main(string[] args) { var computer = new Computer(); var motherboard = new MotherBoard(100); var cpu = new Cpu(200); var ram = new Ram(300); var drive = new Ssd(400); motherboard.Add(cpu); motherboard.Add(ram); computer.Add(motherboard); computer.Add(drive); bool isEqual = computer.Price == 1000; var mPrice = motherboard.Price; var cPrice = cpu.Price; }
static void Main(string[] args) { // pc case composite part Chassis chassis = new Chassis("PC Chassis", 5.0D, 55.00M, 40.00M); // add a mother board and graphics card MotherBoard board = new MotherBoard("ASUS P5QD", 150.0D, 99.99M, 85.50M); chassis.Add(board); Card card = new Card("Nvidia GTS 250", 100.0D, 79.99M, 69.99M); board.Add(card); // and a dvd drive OpticalDrive opticalDrive = new OpticalDrive("DVD RW", 10.0D, 21.50M, 15.99M); chassis.Add(opticalDrive); Console.WriteLine("The net price is: " + chassis.TotalCost().ToString()); Console.WriteLine("The discount price is: " + chassis.TotalDiscountCost().ToString()); }