Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var item1 = new Product("Chocolate", 0.99m, 5);

            Console.WriteLine("The product {0} costs {2:C}, there are {3} left in stock. This product is {1}", item1.Name, item1.Description, item1.Price, item1.Stock);

            Console.WriteLine("Which property would you like to edit?");
            var type = Console.ReadLine();
            switch (type)
            {
                case "name":
                    Console.WriteLine("Enter new " + type);
                    item1.Name = Console.ReadLine();
                    break;

                case "price":
                    Console.WriteLine("Enter new " + type);
                    item1.Price = decimal.Parse(Console.ReadLine());
                    break;

                case "stock":
                    Console.WriteLine("Enter new " + type);
                    item1.Stock = int.Parse(Console.ReadLine());
                    break;

                case "description":
                    Console.WriteLine("Enter new " + type);
                    item1.Description = Console.ReadLine();
                    break;
                default:
                    break;
            }
            Console.WriteLine("The product {0} costs {2:C}, there are {3} left in stock. This product is {1}", item1.Name, item1.Description, item1.Price, item1.Stock);
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var hairGel = new Product("Hair Gel", 5, 100);

            var name = hairGel.Name;
            var price = hairGel.Price;
            var units = hairGel.UnitsInStock;
            var description = hairGel.Description;
            var output = String.Format("Product Name: {0}\n Price: {1}\n Units In Stock: {2}\n Description: {3} \n", name, price, units, description);

            Console.WriteLine(output);

            hairGel.Name = "Super Duper Gel";
            hairGel.Price = 10;
            hairGel.UnitsInStock = 200;
            hairGel.Description = "Super hold gel";
            name = hairGel.Name;
            price = hairGel.Price;
            units = hairGel.UnitsInStock;
            description = hairGel.Description;

            output = String.Format("Product Name: {0}\n Price: {1}\n Units In Stock: {2}\n Description: {3} \n ", name, price, units, description);
            Console.WriteLine(output);
            Console.ReadLine();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var product = new Product("IPhone",1000m,3,"Limited Quality");
            var product1 = new Product("Iphone6", 100m, 3);

            var display = String.Format("{0} {1} {2} {3}",product.Name, product.Price, product.UnitInStock,product.Description);
            Console.WriteLine(display);
            Console.ReadLine();
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var milk = new Product("Milk", 2.99m, 30);
            var apple = new Product("Apple", 0.79m, 25, "Delcious Red Apple");

            Console.WriteLine(milk.ToString());
            Console.WriteLine(apple.ToString());

            Console.ReadLine();
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var couch = new Product("Couch", 400.00m, 5)
            {
                Description = "Brown, leather, two pillows included"
            };

            var chair = new Product("Chair", 250.99m, 8) 
            { 
                UnitsInStock = 2
            };

            Console.WriteLine("Name: {0}, Price: {1:c}, Units In Stock: {2}, Description: {3}", couch.Name, couch.Price, couch.UnitsInStock, couch.Description);
            Console.WriteLine("Name: {0}, Price: {1:c}, Units In Stock: {2}", chair.Name, chair.Price, chair.UnitsInStock);

            Console.ReadLine();

        }