Inheritance: Feline
Example #1
1
 public Cat fromNode(XmlNode node)
 {
     Cat obj = null;
     if (node.Name == "bobcat")
     {
         obj = new Bobcat();
         ((Bobcat)obj).hear_count = Convert.ToInt64(node.Attributes[0].Value);
         ((Bobcat)obj).cat_type = node.Attributes[1].Value;
         obj.age = Convert.ToInt32(node.Attributes[3].Value);
         obj.name = node.Attributes[2].Value;
         obj.weight = Convert.ToSingle(node.Attributes[4].Value);
     }
     if (node.Name == "tiger")
     {
         obj = new Tiger();
         ((Tiger)obj).location = node.Attributes[0].Value;
         ((Tiger)obj).color = node.Attributes[1].Value;
         ((Tiger)obj).height = Convert.ToSingle(node.Attributes[2].Value);
         ((Tiger)obj).is_hungry = Convert.ToBoolean(node.Attributes[3].Value);
         obj.age = Convert.ToInt32(node.Attributes[5].Value);
         obj.name = node.Attributes[4].Value;
         obj.weight = Convert.ToSingle(node.Attributes[6].Value);
     }
     return obj;
 }
Example #2
1
 public List<Cat> Load()
 {
     List<Cat> lst = new List<Cat>();
     FileStream fs = new FileStream(path_to_file, FileMode.OpenOrCreate);
     StreamReader sr = new StreamReader(fs, Encoding.UTF8);
     SAX_parser parser = new SAX_parser(sr);
     Cat obj = null;
     parser.StartTag += (tag_name) =>
     {
         if (tag_name == "bobcat") { obj = new Bobcat(); }
         if (tag_name == "tiger") { obj = new Tiger(); }
     };
     parser.Characters += (name,value) =>
     {
         switch (name)
         {
             case "name": { obj.name = value; break; }
             case "age": { obj.age = Convert.ToInt32(value);  break; }
             case "weight": { obj.weight = Convert.ToSingle(value); break; }
             case "hear_count": { ((Bobcat)(obj)).hear_count = Convert.ToInt64(value); break; }
             case "cat_type": { ((Bobcat)(obj)).cat_type = value; break; }
             case "location": { ((Tiger)(obj)).location = value; break; }
             case "color": { ((Tiger)(obj)).color = value; break; }
             case "height": { ((Tiger)(obj)).height = Convert.ToSingle(value); break; }
             case "is_hungry": { ((Tiger)(obj)).is_hungry = Convert.ToBoolean(value); break; }
         }
     };
     parser.EndTag += (tag_name) =>
         {
             if (tag_name == "bobcat" || tag_name == "tiger")
             {
                 lst.Add(obj);
             }
         };
     parser.start();
     sr.Close();
     fs.Close();
     return lst;
 }
Example #3
0
        public void TigerCanSpeakitsName()
        {
            Tiger  tiger = new Tiger();
            string name  = "Teddy";

            Assert.Equal(name, tiger.Speak(name));
        }
Example #4
0
 public EVMForm(Tiger.Ruma.WcfInterface.IRumaControlClient ruma, Tiger.Ruma.IRumaCpriDataFlow IRumacdf)
 {
     InitializeComponent();
     this.rumaclient = ruma;
     this.Rumacdf = IRumacdf;
     evmtimer.Tick += new EventHandler(evmtimer_tick);
 }
Example #5
0
        public Animal GetAnimal(string[] arr, Food food)
        {
            string type   = arr[0].ToLower();
            string name   = arr[1];
            double weight = double.Parse(arr[2]);
            Animal animal;

            switch (type)
            {
            case "cat":
                animal = new Cat(name, weight, arr[3], arr[4]);
                return(animal);

            case "tiger":
                animal = new Tiger(name, weight, arr[3], arr[4]);
                return(animal);

            case "dog":
                animal = new Dog(name, weight, arr[3]);
                return(animal);

            case "mouse":
                animal = new Mouse(name, weight, arr[3]);
                return(animal);

            case "owl":
                animal = new Owl(name, weight, double.Parse(arr[3]));
                return(animal);

            case "hen":
                animal = new Hen(name, weight, double.Parse(arr[3]));
                return(animal);
            }
            return(null);
        }
Example #6
0
        public static void RunDemo()
        {
            var bengalTiger = new Tiger("Razor", 1);
            var whiteTiger  = new Tiger("Kali", 0);
            var brownTiger  = new Tiger("Chochko", 1);
            var megaTiger   = new Tiger("SBTech Tiger", 2);
            var lameTiger   = new Tiger("Obicham da qm", 21);

            var peshoTheKeeper = new ZooKeeper();
            var goshoTheKeeper = new ZooKeeper();

            var zoo = new Zoo();

            zoo.AddAnimal(bengalTiger);
            zoo.AddAnimal(whiteTiger);
            zoo.AddAnimal(brownTiger);
            zoo.AddAnimal(megaTiger);
            zoo.AddAnimal(lameTiger);

            peshoTheKeeper.Assign(bengalTiger);
            peshoTheKeeper.Assign(whiteTiger);

            goshoTheKeeper.Assign(brownTiger);
            goshoTheKeeper.Assign(megaTiger);
            goshoTheKeeper.Assign(lameTiger);

            zoo.AddZooKeeper(peshoTheKeeper);
            zoo.AddZooKeeper(goshoTheKeeper);

            for (int i = 0; i < 120; i++)
            {
                zoo.TriggerCycle();
            }
        }
Example #7
0
        public Animal GenerateAnimal(string type, string name, double weight, string[] cmdArgs)
        {
            Animal animal = null;

            switch (type)
            {
            case "Owl":
                animal = new Owl(name, weight, double.Parse(cmdArgs[3]));
                break;

            case "Hen":
                animal = new Hen(name, weight, double.Parse(cmdArgs[3]));
                break;

            case "Cat":
                animal = new Cat(name, weight, cmdArgs[3], cmdArgs[4]);
                break;

            case "Tiger":
                animal = new Tiger(name, weight, cmdArgs[3], cmdArgs[4]);
                break;

            case "Mouse":
                animal = new Mouse(name, weight, cmdArgs[3]);
                break;

            case "Dog":
                animal = new Dog(name, weight, cmdArgs[3]);
                break;
            }

            return(animal);
        }
        static void Main(string[] args)
        {
            //Classes
            //Pais e filhos se convertem, porém irmãos não (Polimorfismo)

            Animal a1;
            Tiger  t1;

            //Implicit casting
            t1 = new Tiger();
            a1 = t1;

            Animal a2;
            Tiger  t2;

            //Explicit casting
            t2 = new Tiger();
            a2 = (Animal)t2;

            //Variáveis
            int    a = int.Parse("100");
            string b = Convert.ToString(a);
            double c = (double)a;
            int    d = (int)c;
        }
Example #9
0
        private Animal GetAnimal(string command)
        {
            string[] animalArgs = command
                                  .Split(' ')
                                  .ToArray();

            string type   = animalArgs[0];
            string name   = animalArgs[1];
            double weight = double.Parse(animalArgs[2]);

            Animal animal;

            if (type == "Owl")
            {
                double wingSize = double.Parse(animalArgs[3]);

                animal = new Owl(name, weight, wingSize);
            }
            else if (type == "Hen")
            {
                double wingSize = double.Parse(animalArgs[3]);

                animal = new Hen(name, weight, wingSize);
            }
            else
            {
                string livingRegion = animalArgs[3];

                if (type == "Dog")
                {
                    animal = new Dog(name, weight, livingRegion);
                }
                else if (type == "Mouse")
                {
                    animal = new Mouse(name, weight, livingRegion);
                }
                else
                {
                    string breed = animalArgs[4];

                    if (type == "Cat")
                    {
                        animal = new Cat(name, weight, livingRegion, breed);
                    }
                    else if (type == "Tiger")
                    {
                        animal = new Tiger(name, weight, livingRegion, breed);
                    }
                    else
                    {
                        throw new InvalidOperationException("Invalid animal type!");
                    }
                }
            }

            this.animals.Add(animal);

            return(animal);
        }
Example #10
0
        public void CanTigerSleep()
        {
            Tiger tiger = new Tiger();

            string outcome = tiger.Sleeping();

            Assert.Equal("Zzz to the dream land", outcome);
        }
Example #11
0
        private void btn_tiger_Click(object sender, EventArgs e)
        {
            Graphics    ghs    = this.CreateGraphics();
            IDrawAnimal animal = new Tiger();

            animal.ShowAnimal(ghs, 90, 60);
            ghs.Dispose();
        }
Example #12
0
        public void WhatBloodTempDoesTigerHave()
        {
            Tiger tiger = new Tiger();

            string bloodType = tiger.BloodTemperature;

            Assert.Equal("Warm", bloodType);
        }
Example #13
0
    private static Animal AddTiger(Collection <IAnimal> animals, string[] animalParams)
    {
        Tiger tiger = new Tiger(animalParams[1], double.Parse(animalParams[2]), animalParams[3], animalParams[4]);

        animals.Add(tiger);

        return(tiger);
    }
Example #14
0
        public void TigerCanHuntMonkey()
        {
            Tiger         tiger  = new Tiger();
            HowlerMonkeys monkey = new HowlerMonkeys();


            Assert.Equal("Monkey", tiger.Hunt(monkey));
        }
Example #15
0
    public void TigerHuntReturnString()
    {
        Tiger  testObj  = new Tiger();
        string actual   = testObj.Hunt();
        string expected = typeof(Tiger).Name + " hunts ";

        StringAssert.StartsWith(expected, actual, "Hunt() doesn't work");
    }
Example #16
0
        public static void Main(string[] args)
        {
            Tiger t1 = new Tiger("tiger", 100);
            Lion  l1 = new Lion("lion", 200);

            t1.Show();
            l1.Show();
        }
Example #17
0
    static void Main()
    {
        Sheep x = new Sheep();
        Console.WriteLine(x.Call()); //baaah

        Tiger y = new Tiger();
        Console.WriteLine(y.Call());
    }
 private static void HuntIfYouAreATiger(Animal animal)
 {
     if (animal is Tiger)
     {
         Tiger tiger = (Tiger)animal;
         Console.WriteLine(tiger.Hunt());
     }
 }
Example #19
0
        public static void Example1()
        {
            Tiger tiger = new Tiger();
            Cat   cat   = new Cat();

            Meat meat = tiger.GetFood();
            Milk milk = cat.GetFood();
        }
Example #20
0
        public static void Main(string[] args)
        {
            var tiger = new Tiger(100, "Tiger");
            var lion  = new Lion(200, "Liom");

            tiger.Show();
            lion.Show();
        }
Example #21
0
        public static void Main(string[] args)
        {
            Lion  l1 = new Lion("Lion1", 200);
            Tiger t1 = new Tiger("Tiger1", 100);

            l1.Show();
            t1.Show();
        }
Example #22
0
        public void TigerCanHuntOstrich()
        {
            Tiger   tiger = new Tiger();
            Ostrich mon   = new Ostrich();


            Assert.Equal("Ostrich", tiger.Hunt(mon));
        }
Example #23
0
        public static void Writer(string filePath, List <Animal> list, bool removed)
        {
            foreach (var animal in list)
            {
                if (animal is Tiger)
                {
                    Tiger tiger = animal as Tiger;

                    if (removed)
                    {
                        FileReader.preConvertion.Add(nameof(tiger) + "|" + tiger.Name + "|" + tiger.Age + "|" + tiger.Id + "|" + tiger.Weight + "|" + tiger.Length +
                                                     "|Removed|" + DateTime.Now.ToString("MM/dd/yyyy HH:mm"));
                    }
                    else
                    {
                        FileReader.preConvertion.Add(nameof(tiger) + "|" + tiger.Name + "|" + tiger.Age + "|" + tiger.Id + "|" + tiger.Weight + "|" + tiger.Length);
                    }
                }
                else if (animal is Owl)
                {
                    Owl owl = animal as Owl;

                    if (removed)
                    {
                        FileReader.preConvertion.Add(nameof(owl) + "|" + owl.Name + "|" + owl.Age + "|" + owl.Id + "|" + owl.Weight + "|" + owl.Length +
                                                     "|" + owl.Wingspan + "|" + owl.Clawsize + "|" + owl.Beaksize + "|Removed|" + DateTime.Now.ToString("MM/dd/yyyy HH:mm"));
                    }
                    else
                    {
                        FileReader.preConvertion.Add(nameof(owl) + "|" + owl.Name + "|" + owl.Age + "|" + owl.Id + "|" + owl.Weight + "|" + owl.Length +
                                                     "|" + owl.Wingspan + "|" + owl.Clawsize + "|" + owl.Beaksize);
                    }
                }
                else if (animal is Elephant)
                {
                    Elephant elephant = animal as Elephant;

                    if (removed)
                    {
                        FileReader.preConvertion.Add(nameof(elephant) + "|" + elephant.Name + "|" + elephant.Age + "|" + elephant.Id + "|" + elephant.Weight + "|" + elephant.Length +
                                                     "|" + elephant.Trunklenth + "|Removed|" + DateTime.Now.ToString("MM/dd/yyyy HH:mm"));
                    }
                    else
                    {
                        FileReader.preConvertion.Add(nameof(elephant) + "|" + elephant.Name + "|" + elephant.Age + "|" + elephant.Id + "|" + elephant.Weight + "|" + elephant.Length +
                                                     "|" + elephant.Trunklenth);
                    }
                }
            }

            foreach (var thing in FileReader.preConvertion)
            {
                Console.WriteLine("**" + thing);
            }

            File.WriteAllLines(filePath, FileReader.preConvertion);
            FileReader.preConvertion.Clear();
        }
Example #24
0
        private static void FeedAnimals()
        {
            var input = string.Empty;

            while ((input = Console.ReadLine()) != "End")
            {
                var animalInformation = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                var foodInformation   = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                Animal.Animal currentAnimal = null;
                Food.Food     currentFood   = null;

                var animalType   = animalInformation[0];
                var animalName   = animalInformation[1];
                var animalWeight = double.Parse(animalInformation[2]);
                var animalRegion = animalInformation[3];
                var animalBreed  = string.Empty;
                if (animalType == "Cat")
                {
                    animalBreed   = animalInformation[4];
                    currentAnimal = new Cat(animalName, animalType, animalWeight, animalRegion, animalBreed);
                }
                else
                {
                    switch (animalType)
                    {
                    case "Tiger":
                        currentAnimal = new Tiger(animalName, animalType, animalWeight, animalRegion);
                        break;

                    case "Zebra":
                        currentAnimal = new Zebra(animalName, animalType, animalWeight, animalRegion);
                        break;

                    case "Mouse":
                        currentAnimal = new Mouse(animalName, animalType, animalWeight, animalRegion);
                        break;
                    }
                }

                var foodType   = foodInformation[0];
                var foodAmount = int.Parse(foodInformation[1]);

                if (foodType == "Vegetable")
                {
                    currentFood = new Vegetable(foodAmount);
                }
                else if (foodType == "Meat")
                {
                    currentFood = new Meat(foodAmount);
                }

                currentAnimal.makeSound();
                currentAnimal.eatFood(currentFood);

                Console.WriteLine(currentAnimal);
            }
        }
Example #25
0
        private static Animal CreateAnimal(string[] animalInfo)
        {
            Animal animal = null;

            if (animalInfo[0] == "Owl")
            {
                string name     = animalInfo[1];
                double weight   = double.Parse(animalInfo[2]);
                double wingSize = double.Parse(animalInfo[3]);

                animal = new Owl(name, weight, wingSize);
            }
            else if (animalInfo[0] == "Hen")
            {
                string name     = animalInfo[1];
                double weight   = double.Parse(animalInfo[2]);
                double wingSize = double.Parse(animalInfo[3]);

                animal = new Hen(name, weight, wingSize);
            }
            else if (animalInfo[0] == "Mouse")
            {
                string name         = animalInfo[1];
                double weight       = double.Parse(animalInfo[2]);
                string livingRegion = animalInfo[3];

                animal = new Mouse(name, weight, livingRegion);
            }

            else if (animalInfo[0] == "Dog")
            {
                string name         = animalInfo[1];
                double weight       = double.Parse(animalInfo[2]);
                string livingRegion = animalInfo[3];

                animal = new Dog(name, weight, livingRegion);
            }
            else if (animalInfo[0] == "Cat")
            {
                string name         = animalInfo[1];
                double weight       = double.Parse(animalInfo[2]);
                string livingRegion = animalInfo[3];
                string breed        = animalInfo[4];

                animal = new Cat(name, weight, livingRegion, breed);
            }
            else if (animalInfo[0] == "Tiger")
            {
                string name         = animalInfo[1];
                double weight       = double.Parse(animalInfo[2]);
                string livingRegion = animalInfo[3];
                string breed        = animalInfo[4];

                animal = new Tiger(name, weight, livingRegion, breed);
            }

            return(animal);
        }
Example #26
0
        private Animal CreateAnimal(string[] animalsInfo)
        {
            string animalType = animalsInfo[0];
            string name       = animalsInfo[1];
            double weight     = double.Parse(animalsInfo[2]);

            Animal animal = null;

            switch (animalType)
            {
            case "Owl":

                double wingSizeOwl = double.Parse(animalsInfo[3]);

                animal = new Owl(name, weight, wingSizeOwl);
                break;

            case "Hen":

                double wingSizeHen = double.Parse(animalsInfo[3]);

                animal = new Hen(name, weight, wingSizeHen);
                break;

            case "Mouse":

                string livingRegionMouse = animalsInfo[3];

                animal = new Mouse(name, weight, livingRegionMouse);
                break;

            case "Dog":

                string livingRegionDog = animalsInfo[3];

                animal = new Dog(name, weight, livingRegionDog);
                break;

            case "Cat":

                string livingRegionCat = animalsInfo[3];
                string breedCat        = animalsInfo[4];

                animal = new Cat(name, weight, livingRegionCat, breedCat);
                break;

            case "Tiger":

                string livingRegionTiger = animalsInfo[3];
                string breedTiger        = animalsInfo[4];

                animal = new Tiger(name, weight, livingRegionTiger, breedTiger);
                break;
            }

            return(animal);
        }
Example #27
0
    private static Animal AddAnimal(List <Animal> animals, string input)
    {
        string[] aniArg = input.Split();
        string   name   = aniArg[1];
        double   weight = double.Parse(aniArg[2]);

        switch (aniArg[0])
        {
        case "Owl":
            double wingSize = double.Parse(aniArg[3]);
            Animal owl      = new Owl(name, weight, 0, wingSize);
            Console.WriteLine(owl.ProduceSound);
            // animals.Add(owl);
            return(owl);

        case "Hen":
            double wings = double.Parse(aniArg[3]);
            Animal hen   = new Hen(name, weight, 0, wings);
            Console.WriteLine(hen.ProduceSound);
            // animals.Add(hen);
            return(hen);

        case "Mouse":
            string livingRegion = aniArg[3];
            Animal mouse        = new Mouse(name, weight, livingRegion);
            Console.WriteLine(mouse.ProduceSound);
            // animals.Add(mouse);
            return(mouse);

        case "Dog":
            string livingR = aniArg[3];
            Animal dog     = new Dog(name, weight, livingR);
            Console.WriteLine(dog.ProduceSound);
            // animals.Add(dog);
            return(dog);

        case "Cat":
            string livReg = aniArg[3];
            string breed  = aniArg[4];
            Animal cat    = new Cat(name, weight, livReg, breed);
            Console.WriteLine(cat.ProduceSound);
            // animals.Add(cat);
            return(cat);

        case "Tiger":
            string lReg  = aniArg[3];
            string br    = aniArg[4];
            Animal tiger = new Tiger(name, weight, lReg, br);
            Console.WriteLine(tiger.ProduceSound);
            //  animals.Add(tiger);
            return(tiger);


        default:
            return(null);
        }
    }
Example #28
0
        public void TestCanCreateTigerWithInheritanceAndInterface()
        {
            //Arrange
            //Act
            Tiger Tiaga = new Tiger("Tiaga the Tiger", "Female");

            //Assert
            Assert.Contains("Carnivore", Tiaga.Prey);
        }
        public Animal ProduceAnimal(string[] animalArgs)
        {
            Animal animal = null;
            var    type   = animalArgs[0];
            var    name   = animalArgs[1];

            switch (type)
            {
            case "Cat":
            case "Tiger":
                var    weight       = double.Parse(animalArgs[2]);
                string livingRegion = animalArgs[3];
                string breed        = animalArgs[4];
                if (type == "Cat")
                {
                    animal = new Cat(name, weight, livingRegion, breed);
                }
                else if (type == "Tiger")
                {
                    animal = new Tiger(name, weight, livingRegion, breed);
                }
                break;

            case "Dog":
            case "Mouse":
                weight       = double.Parse(animalArgs[2]);
                livingRegion = animalArgs[3];
                if (type == "Dog")
                {
                    animal = new Dog(name, weight, livingRegion);
                }
                else if (type == "Mouse")
                {
                    animal = new Mouse(name, weight, livingRegion);
                }
                break;

            case "Owl":
            case "Hen":
                weight = double.Parse(animalArgs[2]);
                var wingSize = double.Parse(animalArgs[3]);
                if (type == "Owl")
                {
                    animal = new Owl(name, weight, wingSize);
                }
                else if (type == "Mouse")
                {
                    animal = new Hen(name, weight, wingSize);
                }
                break;

            default:
                throw new ArgumentException($"Invalid input!");
            }
            return(animal);
        }
Example #30
0
        public IAnimal CreateAnimal(string[] animalData)
        {
            IAnimal animal = null;

            var type   = animalData[0];
            var name   = animalData[1];
            var weight = double.Parse(animalData[2]);

            switch (type)
            {
            case "Owl":
            case "Hen":
                var wingSize = double.Parse(animalData[3]);

                if (type == "Owl")
                {
                    animal = new Owl(name, weight, wingSize);
                }
                else if (type == "Hen")
                {
                    animal = new Hen(name, weight, wingSize);
                }
                break;

            case "Mouse":
            case "Dog":
            case "Cat":
            case "Tiger":
                var livingRegion = animalData[3];

                if (type == "Mouse")
                {
                    animal = new Mouse(name, weight, livingRegion);
                }
                else if (type == "Dog")
                {
                    animal = new Dog(name, weight, livingRegion);
                }
                else if (type == "Cat" || type == "Tiger")
                {
                    var breed = animalData[4];

                    if (type == "Cat")
                    {
                        animal = new Cat(name, weight, livingRegion, breed);
                    }
                    else if (type == "Tiger")
                    {
                        animal = new Tiger(name, weight, livingRegion, breed);
                    }
                }
                break;
            }

            return(animal);
        }
Example #31
0
    static void Main(string[] args)
    {
        Dog d = new Dog {
            Age = 37, Name = "Nick"
        };
        Tiger t = d.ConvertTo <Dog, Tiger>();

        Debug.Assert(t.Name == d.Name);
        Debug.Assert(t.Age == d.Age);
    }
Example #32
0
        public static void Main(string[] args)
        {
            Lion  l = new Lion(0, "");
            Tiger t = new Tiger(0, "");

            l.setMe(200, "Lion");
            t.setMe(100, "Tiger");
            l.Show();
            t.Show();
        }
Example #33
0
        public static void Main(string[] args)
        {
            Lion  lion  = new Lion("", 0);
            Tiger tiger = new Tiger("", 0);

            lion.SetMe("lion", 200);
            tiger.SetMe("tiger", 100);
            lion.Show();
            tiger.Show();
        }
Example #34
0
        public static void Main(string[] args)
        {
            string name;
            int    weight;
            Lion   l = new Lion("Lion", 100);
            Tiger  t = new Tiger("Tiger", 200);

            l.Show();
            t.Show();
        }
Example #35
0
    static void Main()
    {
        AnimalsMain newAnimal = new AnimalsMain { };
        newAnimal.PrintData();

        Console.WriteLine();
        Console.WriteLine("Tiger");
        Console.WriteLine();

        // Here we create a custom tiger with pre generated
        // specs based on the level
        // We get the specs from a ready TXT file
        Tiger customTiger = new Tiger
        {
            Name = "Snow Tiger",
            Level = 99,
            FavoriteFood = "Mutton",
            CriticalChance = 10.1
        };

        customTiger.PrintData();

        Console.WriteLine();
        Console.WriteLine(" -- Plants -- ");
        Console.WriteLine();

        PlantsMain newPlant = new PlantsMain
        {
            Age = 1, Name = "Lale", Height = 4.12,Type = "Flower",Area = "BG"
        };

        newPlant.PrintData();

        Tiger newTiger = new Tiger();
        newTiger.Level = 1;
        newTiger.PrintData();

        Console.WriteLine("--- test ---");

        AnimalsMain Bear = new AnimalsMain();

        Bear.Characteristics = "Birds";
        Bear.Damage = 1;
        Bear.PrintData();
    }
Example #36
0
    public static Animal Make(AnimalType type) {
        Animal result = null;

        switch (type)
        {
            case AnimalType.Bear:
                result = new Bear();
                break;            
            case AnimalType.Dragon:
                result = new Dragon();
                break;            
            default:
                result = new Tiger();
                break;            
        } 

        return result;
    }
Example #37
0
        static void Main()
        {
            Tiger tiger = new Tiger();
            Tiger anotherTiger = new Tiger("as");
            IAnimal otherTiger = new Tiger();

            WriteLine($"Tiger: {tiger.Name}");
            WriteLine($"Damage: {tiger.Damage}");
            WriteLine($"Defence: {tiger.Defence}");
            WriteLine($"Health: {tiger.Health}");

            WriteLine($"AnotherTiger: {anotherTiger.Name}");
            WriteLine($"Damage: {anotherTiger.Damage}");
            WriteLine($"Defence: {anotherTiger.Defence}");
            WriteLine($"Health: {anotherTiger.Health}");

            //This tiger does not contain name, beacuse we said he is IAnimal
            //IAnimal does not have name
            WriteLine($"OtherTiger: "); 
            WriteLine($"Damage: {otherTiger.Damage}");
            WriteLine($"Defence: {otherTiger.Defence}");
            WriteLine($"Health: {otherTiger.Health}");
            
        }
Example #38
0
        //rumaster stop
        private void RumasterStopPlayBack(string cpriport,Tiger.Ruma.FlowDataType[] flows)
        {
            try
            {

                icdf.StopPlayBack(cpriport, flows);
            }
            catch
            {
                WriteTraceText("Rumaster stopplayback failed!");

            }
        }