Beispiel #1
0
        static void Main(string[] args)
        {
            Dog myDog = new Dog();

            Console.Write("Hello! Please insert your dog's name: ");
            myDog.Name = Console.ReadLine();
            Console.Write("Now insert the dog's race: ");
            myDog.Race = Console.ReadLine();
            Console.Write("Insert the color of your dog: ");
            myDog.Color = Console.ReadLine();
            while (true)
            {
                Console.Clear();
                Console.WriteLine($"{myDog.Name} is {myDog.Color} colored {myDog.Race} :)");
                Console.WriteLine($"What {myDog.Name} likes to do most? Please insert the number");
                Console.WriteLine("1) Eat");
                Console.WriteLine("2) Play");
                Console.WriteLine("3) Chase its tail");
                bool isNum = int.TryParse(Console.ReadLine(), out int number);
                if (!isNum || number < 1 || number > 3)
                {
                    Console.WriteLine("Please press enter and insert valid number!");
                    Console.ReadLine();
                }
                else
                {
                    switch (number)
                    {
                    case 1:
                        myDog.Eat();
                        break;

                    case 2:
                        myDog.Play();
                        break;

                    case 3:
                        myDog.ChaseTail();
                        break;

                    default:
                        continue;
                    }
                    Console.ReadLine();
                    break;
                }
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Congratulations on buying a new dog! ^_^");
            Console.WriteLine("What's the dog's name?");
            string dogName = Console.ReadLine();

            Console.WriteLine("What race is it?");
            string dogRace = Console.ReadLine();

            Console.WriteLine("What color is it?");
            string dogColor = Console.ReadLine();


            Dog doggo1 = new Dog(dogName, dogRace, dogColor);

            Console.WriteLine("___________________________");
            Console.WriteLine("What do you want the dog to do?");
            Console.WriteLine($"Type in 'A' to make {doggo1.Name} eat.");
            Console.WriteLine($"Type in 'B' to make {doggo1.Name} play.");
            Console.WriteLine($"Type in 'C' to make {doggo1.Name} chase its tail.");
            string userInput = Console.ReadLine();

            switch (userInput)
            {
            case "A":
                Console.WriteLine(doggo1.Eat());
                break;

            case "B":
                Console.WriteLine(doggo1.Play());
                break;

            case "C":
                Console.WriteLine(doggo1.ChaseTail());
                break;

            default:
                Console.WriteLine("The dog is looking at you all confused...");
                break;
            }



            Console.ReadKey();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            while (true)
            {
                Dog myDog = new Dog();

                Console.WriteLine("Enter the dog's name:");
                myDog.Name = Console.ReadLine();

                if (myDog.Name == "")
                {
                    Console.WriteLine("Invalid input");
                    continue;
                }

                while (true)
                {
                    Console.WriteLine("Enter the dog's race:");
                    myDog.Race = Console.ReadLine();

                    if (myDog.Race == "")
                    {
                        Console.WriteLine("Invalid input");
                        continue;
                    }
                    break;
                }

                while (true)
                {
                    Console.WriteLine("Enter the dog's color:");
                    myDog.Color = Console.ReadLine();

                    if (myDog.Color == "")
                    {
                        Console.WriteLine("Invalid input");
                        continue;
                    }
                    break;
                }

                Console.WriteLine($"Your dog name is {myDog.Name}, its race is {myDog.Race} and his color is {myDog.Color}");

                while (true)
                {
                    Console.WriteLine(@"Choose the activity you want for your dog For your dog to eat press: 1 For your dog to play press: 2 For your dog to chase his tail press: 3");

                    bool activitySuccess = int.TryParse(Console.ReadLine(), out int activity);

                    if (!activitySuccess || activity < 1 || activity > 3)
                    {
                        Console.WriteLine("Ivalid input");
                        continue;
                    }

                    switch (activity)
                    {
                    case 1:
                        myDog.Eat();
                        break;

                    case 2:
                        myDog.Play();
                        break;

                    case 3:
                        myDog.ChaseTail();
                        break;
                    }

                    break;
                }
                break;
            }

            Console.ReadLine();
        }