예제 #1
0
        static void Main(string[] args)
        {
            NewCar tesla = new NewCar();
            tesla.Model = "Modle S";
            tesla.Price = 27877.99m;
            tesla.VIN = "2349898wjc8w92r";

            UsedCar usedToyota = new UsedCar();

            CertifiedUsedCar jaguar = new CertifiedUsedCar();

            Car[] inventory = new Car[]
            {
                new UsedCar {VIN="78YSDDFSD45", Price=17000m},
                new CertifiedUsedCar {VIN="888SDDFSD45", Price=17000m},
                new NewCar {VIN="YIUIU66II77", Price=44000m},
                new UsedCar {VIN="3NBMM99887", Price=12000m},
                new UsedCar {VIN="55555OOOOOP", Price=11000m}

            };

            decimal total = 0;
            foreach (Car car in inventory)
            {
                if (car is UsedCar)
                {
                    total += car.Price;
                }

            }

            Console.WriteLine("Total inventory value: " + total.ToString("c"));
            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            NewCar tesla = new NewCar();
            tesla.Model = "Model S";
            tesla.Price = 283473472983742.239844m;
            tesla.VIN = "2387429837293";

            UsedCar usedToyota = new UsedCar();
            usedToyota.Price = 8734.273m;
            usedToyota.CalculateTax();

            CertifiedUsedCar jaguar = new CertifiedUsedCar();

            Car[] inventory = new Car[]
            {
                new UsedCar { VIN = "234982738", Price = 17000m },
                new CertifiedUsedCar { VIN = "7873483", Price = 17000m },
                new NewCar { VIN = "37f83723", Price = 44000m },
                new UsedCar { VIN = "e72338574", Price = 12000m },
                new UsedCar { VIN = "9723874538", Price = 11000m }
            };

            decimal total = 0;
            foreach(Car car in inventory)
            {
                if (car is UsedCar)
                {
                    total = total + car.Price;
                }
            }

            Console.WriteLine("Total inventory value: " + total.ToString("c"));
            Console.ReadLine();
        }