예제 #1
0
        static void Main(string[] args)
        {
            Dog dog = new Dog("Tuutikki", 2, "Japanese Spitz", "Saara Virtanen", "Dino", 10);
            Console.WriteLine("Dog information:");
            dog.PrintData();
            dog.Bark();

            Console.WriteLine();

            Cat cat = new Cat("Kisu", 5, "Birman", "Kirsi Kernel", true);
            Console.WriteLine("Cat information:");
            cat.PrintData();
            cat.Meow();

            Console.WriteLine();

            Hamster hamster = new Hamster("Tarmo", 1, "Syrian hamster", "Matti Meikäläinen", "40 x 50 x 30 cm", "Long-haired cream roan");
            Console.WriteLine("Hamster information:");
            hamster.PrintData();
            hamster.FillCheeks();

            /*
            TULOSTAA:
            Dog information:
            Name: Tuutikki
            Age: 2
            Breed: Japanese Spitz
            Owner: Saara Virtanen
            Favourite toy: Dino
            Toy count: 10
            Woof!

            Cat information:
            Name: Kisu
            Age: 5
            Breed: Birman
            Owner: Kirsi Kernel
            Is furry: True
            Meow!

            Hamster information:
            Name: Tarmo
            Age: 1
            Breed: Syrian hamster
            Owner: Matti Meikäläinen
            Terrarium size: 40 x 50 x 30 cm
            Type: Long-haired cream roan
            Hamster's cheeks are full of food!
            */
        }
예제 #2
0
파일: Program.cs 프로젝트: H8262/Demo04
        static void Main(string[] args)
        {
            Cat cat = new Cat(4);
            Doge doge = new Doge(4);

            int i = 1;
            int menu = 0;

            do
            {
                Console.WriteLine("Choose animal!");
                Console.WriteLine("1. Cat");
                Console.WriteLine("2. Dog");
                Console.WriteLine("3. Abandon animals!");
                menu = int.Parse(Console.ReadLine());

                switch (menu)
                {
                    case 1:
                        {
                            Console.WriteLine("This cat has : " + cat.Legs + " legs");
                            cat.CatMethod();
                            break;
                        }
                    case 2:
                        {
                            Console.WriteLine("This dog has : " + doge.Legs + " legs");
                            doge.DogeMethod();
                            break;
                        }
                    case 3:
                        {
                            Console.WriteLine("Animals require your attention!");
                            i = 0;
                            break;
                        }                     
                }
            } while (i == 1);

        }