Пример #1
0
        static void Main(string[] args)
        {
            Dog aDog = new Dog();
            Console.WriteLine(aDog.ToString());

            Dog myDog = new Dog("Fido");
            myDog.Weight = 45;
            myDog.Noise();
            Console.WriteLine(myDog.ToString());

            Cat myCat = new Cat("Pus");
            myCat.Weight = 12;
            myCat.Noise();
            Console.WriteLine(myCat.ToString());
        }
Пример #2
0
        static void Main(string[] args)
        {
            //Dog class
            Dog d = new Dog();
            List<Animal> animals = new List<Animal>();
            animals.Add(new Dog());
            animals.Add(new Cat());
            animals.Add(new Cow());

            foreach (Animal ani in animals)
            {
                ani.Name();
                ani.Age();
                ani.Speak();
                ani.Move();

                d.Eat();
                d.Sleep();
            }

            Console.ReadKey();
        }
Пример #3
0
        static void Main(string[] args)
        {
            // Create an Animal object and call the constructor
            Animal spot = new Animal(15, 10, "Spot", "Woof");

            // Get object values with the dot operator
            Console.WriteLine("{0} says {1}", spot.name, spot.sound);

            // Calling a static method
            Console.WriteLine("Number of Animals " + Animal.getNumOfAnimals());

            // Calling an object method
            Console.WriteLine(spot.toString());

            Console.WriteLine("3 + 4 = " + spot.getSum(3, 4));

            // You can assign attributes by name
            Console.WriteLine("3.4 + 4.5 = " + spot.getSum(num2: 3.4, num1: 4.5));

            // You can create objects with an object initializer
            Animal grover = new Animal
            {
                name = "Grover",
                height = 16,
                weight = 18,
                sound = "Grrr"
            };

            Console.WriteLine(grover.toString());

            // Create a subclass Dog object
            Console.WriteLine("");
            Console.WriteLine("This Dog subclass inherits all the Animal class methods and variables");
            Dog spike = new Dog();
            
            //Console.WriteLine(spike.toString());

            spike = new Dog(20, 15, "Spike", "Grrr Woof", "Chicken");
            

            Console.WriteLine(spike.toString());
            Console.WriteLine("");

            Console.Write("Hit Enter to Exit");
            string exitApp = Console.ReadLine();

        }
Пример #4
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.Clear();

                Dog        dog        = new Dog();
                Cat        cat        = new Cat();
                Lizard     lizard     = new Lizard();
                Snake      snake      = new Snake();
                Turtle     turtle     = new Turtle();
                Hamster    hamster    = new Hamster();
                DryFeed    dryFeed    = new DryFeed();
                LiquidFeed liquidFeed = new LiquidFeed();
                Bone       bone       = new Bone();
                Ball       ball       = new Ball();
                Manager    manager    = new Manager();
                Seller     seller     = new Seller();

                Console.WriteLine("\t\tMenu");
                Console.WriteLine("Enter 1  for know about dog;");
                Console.WriteLine("Enter 2  for know about cat;");
                Console.WriteLine("Enter 3  for know about lizard;");
                Console.WriteLine("Enter 4  for know about snake;");
                Console.WriteLine("Enter 5  for know about turtle;");
                Console.WriteLine("Enter 6  for know about humster;");
                Console.WriteLine("Enter 7  for know about dry feed;");
                Console.WriteLine("Enter 8  for know about liquid feed;");
                Console.WriteLine("Enter 9  for know about bone;");
                Console.WriteLine("Enter 10 for know about ball;");
                Console.WriteLine("Enter 11 for know about manager;");
                Console.WriteLine("Enter 12 for know about seller;");
                Console.WriteLine("Enter 13 for EXIT;");

                int choice = int.Parse(Console.ReadLine());

                switch (choice)
                {
                case 1:
                    dog.GetFullInfo();
                    break;

                case 2:
                    cat.GetFullInfo();
                    break;

                case 3:
                    lizard.GetFullInfo();
                    break;

                case 4:
                    snake.GetFullInfo();
                    break;

                case 5:
                    turtle.GetFullInfo();
                    break;

                case 6:
                    hamster.GetFullInfo();
                    break;

                case 7:
                    dryFeed.GetFullInfo();
                    break;

                case 8:
                    liquidFeed.GetFullInfo();
                    break;

                case 9:
                    bone.GetFullInfo();
                    break;

                case 10:
                    ball.GetFullInfo();
                    break;

                case 11:
                    manager.GetFullInfo();
                    break;

                case 12:
                    seller.GetFullInfo();
                    break;

                case 13:
                    Environment.Exit(0);
                    break;
                }
                Console.ReadKey();
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            Dog Spot = new Dog();

            Spot.move();
        }
 static void Main(string[] args)
 {
     Dog Spot = new Dog();
     Spot.move();
 }
Пример #7
0
 public void WalkWithDog(Dog dog)
 {
     dog.AnimalWalk();
 }