public Computer(string computerName, Component processor, Component graphicCard, Component motherboard, Component ram, Component hdd, Component battery) { this.computerName = computerName; this.processor = processor; this.graphicCard = graphicCard; this.motherboard = motherboard; this.ram = ram; this.hdd = hdd; this.battery = battery; arr[0] = processor; arr[1] = graphicCard; arr[2] = motherboard; arr[3] = ram; arr[4] = hdd; arr[5] = battery; TotalPrice(arr); }
public void TotalPrice(Component[] arr) { decimal sum = 0; for (int i = 0; i < arr.Length; i++) { if (arr[i] != null) { sum += arr[i].ComponentPrice; } } this.totalPrice = sum;//.ToString("#,#.00# lv."); ; }
public Computer(string computerName, Component processor, Component graphicCard, Component motherboard) : this(computerName, processor, graphicCard, motherboard, null, null, null) { }