Пример #1
0
            public static void Main()
            {
                HousePlant plantOne = new HousePlant();
                HousePlant plantTwo = new HousePlant();
                HousePlant plantThree = new HousePlant();
                plantOne.Name = "Rose";
                plantOne.Price = 3.99;
                plantOne.Fed = "fed";
                plantTwo.Name = "Daisy";
                plantTwo.Price = 2.99;
                plantTwo.Fed = "unfed";
                plantThree.Name = "Unknown";
                plantThree.Price = 7.49;
                plantThree.Fed = "fed?";

                Console.WriteLine();
                Console.WriteLine("  The first plant is a {0} {1} that costs {2}", plantOne.Fed, plantOne.Name, plantOne.Price.ToString("C2"));
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("  The second plant is an {0} {1} that costs {2}", plantTwo.Fed, plantTwo.Name, plantTwo.Price.ToString("C2"));
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("  The third plant is a {0} {1} that costs {2}", plantThree.Fed, plantThree.Name, plantThree.Price.ToString("C2"));

                Console.ReadLine();
            }
Пример #2
0
        static void Main(string[] args)
        {
            HousePlant plant1 = new HousePlant();
            HousePlant plant2 = new HousePlant();
            HousePlant plant3 = new HousePlant();

            plant1.Name        = "Daffodil";
            plant1.Price       = 2.3;
            plant1.FedRecently = true;
            plant2.Name        = "Daisy";
            plant2.Price       = 1.7;
            plant2.FedRecently = false;
            plant3.Name        = "Lilac";
            plant3.Price       = 2.93;
            plant3.FedRecently = true;
            Console.WriteLine($"Plant: {plant1.Name}  Price: ${plant1.Price:C}  Needs Water: {plant1.FedRecently}");
            Console.WriteLine($"Plant: {plant2.Name}  Price: ${plant2.Price:C}  Needs Water: {plant2.FedRecently}");
            Console.WriteLine($"Plant: {plant3.Name}  Price: ${plant3.Price:C}  Needs Water: {plant3.FedRecently}");
        }