static void Main(string[] args) { Car car = new Car { Model = "Model", Brand = "Brand", Number = "Number", Cost = 100, MaxDistance = 1000 }; car = new DiscountDecorator(car, 10, 100); car = new RentDecorator(car) { Name = "Name", Surname = "Surname", NumberOfPassport = "NumberOfPassport" }; Console.WriteLine(car.ToString()); }
private void DisplayPrice() { ComputerBase computer = new ComputerBase() { Model = "ExtremeXPC" }; ComputerDecorator ramDecorator; if (rad8RAM.Checked) { ramDecorator = new Memory8Option(computer); } else { ramDecorator = new Memory16Option(computer); } ComputerDecorator ssdDecorator; if (rad128SSD.Checked) { ssdDecorator = new SSD128Option(ramDecorator); } else if (rad256SSD.Checked) { ssdDecorator = new SSD256Option(ramDecorator); } else { ssdDecorator = new SSD512Option(ramDecorator); } ComputerDecorator decorator; if (chkApplyDiscount.Checked) { decorator = new DiscountDecorator(ssdDecorator); } else { decorator = ssdDecorator; } lblModel.Text = decorator.Model + "-" + decorator.GetOptionCode(); lblTotal.Text = decorator.GetPrice().ToString("C"); }