Inheritance: KineticEntity
Exemplo n.º 1
0
		/// <inheritdoc />
		public override void UpdateItems(IEnumerable<Watch> itemsAdresses)
		{
			IEnumerable<Watch> statusWatch = itemsAdresses.Where<Watch>(w => ((long)w.Address) == MapPanel.owlAddress);
			if (statusWatch.Any<Watch>())
			{
				owlsStatus = (Owl)Convert.ToUInt32(statusWatch.First<Watch>().Value);
			}
			foreach (Owl status in handledStatus.Keys)
			{
				if ((status & owlsStatus) == status)
				{
					handledStatus[status].IsEnabled = true;
				}
				else
				{
					handledStatus[status].IsEnabled = false;
				}
			}

			if (owlsStatus == Owl.HiddenOwl && itemsAdresses.Any<Watch>(z => z.Address == CommonAdresses["soarCursor"]))
			{
				int cursor = (int)itemsAdresses.Where<Watch>(z => z.Address == CommonAdresses["soarCursor"]).First<Watch>().Value;
				if (cursor < 10)
				{
					handledStatus[IndexWarp[cursor]].IsDestination = true;
					handledStatus[lastDestination].IsDestination = false;
					lastDestination = IndexWarp[cursor];
                }
				else
				{
					//Sofltlock
				}
			}
		}
Exemplo n.º 2
0
        public Animal ProduceAnimal(string[] args)
        {
            Animal animal = null;
            string type   = args[0];
            string name   = args[1];
            double weight = double.Parse(args[2]);

            if (type == "Owl" || type == "Hen")
            {
                double wingSize = double.Parse(args[3]);
                if (type == "Owl")
                {
                    animal = new Owl(name, weight, wingSize);
                }
                else if (type == "Hen")
                {
                    animal = new Hen(name, weight, wingSize);
                }
            }
            else if (type == "Cat" || type == "Tiger")
            {
                string livingRegion = args[3];
                string breed        = args[4];
                if (type == "Cat")
                {
                    animal = new Cat(name, weight, livingRegion, breed);
                }
                else if (type == "Tiger")
                {
                    animal = new Tiger(name, weight, livingRegion, breed);
                }
            }
            else if (type == "Dog" || type == "Mouse")
            {
                string livingRegion = args[3];
                if (type == "Dog")
                {
                    animal = new Dog(name, weight, livingRegion);
                }
                else if (type == "Mouse")
                {
                    animal = new Mouse(name, weight, livingRegion);
                }
            }

            return(animal);
        }
Exemplo n.º 3
0
    private static Animal ParseAnimal(string input)
    {
        var    inputDetails = input.Split();
        var    animalType   = inputDetails[0];
        var    animalName   = inputDetails[1];
        double weight       = double.Parse(inputDetails[2]);
        string region       = inputDetails[3];

        Animal animal = null;

        switch (animalType)
        {
        case "Mouse":
            region = inputDetails[3];
            animal = new Mouse(animalName, weight, region);
            break;

        case "Dog":
            animal = new Dog(animalName, weight, region);
            break;

        case "Cat":
            string breed = inputDetails[4];
            animal = new Cat(animalName, weight, region, breed);
            break;

        case "Tiger":
            breed  = inputDetails[4];
            animal = new Tiger(animalName, weight, region, breed);
            break;

        case "Owl":
            var owlWingSize = double.Parse(region);
            animal = new Owl(animalName, weight, owlWingSize);
            break;

        case "Hen":
            var wingSize = double.Parse(region);
            animal = new Hen(animalName, weight, wingSize);
            break;

        default:
            throw new ArgumentException("Invalid animal type!");
            // така ако с еподаде несъщ животно ще върне null, а това не добре да го вкарваме в кол-я
        }
        return(animal);
    }
Exemplo n.º 4
0
        private static IAnimal ProduceAnimal(string[] animalArgs)
        {
            IAnimal animal = null;

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

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

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

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

            return(animal);
        }
Exemplo n.º 5
0
    private static Animal ParseAnimal(string evenLine)
    {
        var animalInput = evenLine.Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray();

        var animalType    = animalInput[0];
        var animalName    = animalInput[1];
        var animalWeight  = double.Parse(animalInput[2]);
        var fourtArgument = animalInput[3];

        Animal animal = null;

        switch (animalType)
        {
        case "Cat":
            var catBreed = animalInput[4];
            animal = new Cat(animalName, animalWeight, fourtArgument, catBreed);
            break;

        case "Tiger":
            var tigerBreed = animalInput[4];
            animal = new Tiger(animalName, animalWeight, fourtArgument, tigerBreed);
            break;

        case "Dog":
            animal = new Dog(animalName, animalWeight, fourtArgument);
            break;

        case "Mouse":
            animal = new Mouse(animalName, animalWeight, fourtArgument);
            break;

        case "Owl":
            double wingSize = double.Parse(fourtArgument);
            animal = new Owl(animalName, animalWeight, wingSize);
            break;

        case "Hen":
            double henWingSize = double.Parse(fourtArgument);
            animal = new Hen(animalName, animalWeight, henWingSize);
            break;

        default:
            throw new ArgumentException("Invalid animal type!");
        }

        return(animal);
    }
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (m_enemyLayers == (m_enemyLayers | (1 << collision.gameObject.layer)))
        {
            Owl owl = collision.gameObject.GetComponent <Owl>();
            if (owl)
            {
                owl.ApplyDamage(m_damage);
            }
            else
            {
                Debug.LogError("No owl script on " + collision.gameObject.name);
            }
        }

        Destroy(gameObject);
    }
Exemplo n.º 7
0
    private static Animal GetAnimalInfo(string[] args)
    {
        var    type   = args[0];
        var    name   = args[1];
        var    weight = double.Parse(args[2]);
        Animal animal = null;
        int    wingSize;
        string livingRegion, breed;

        switch (type)
        {
        case "Cat":
            livingRegion = args[3];
            breed        = args[4];
            animal       = new Cat(name, weight, livingRegion, breed);
            break;

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

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

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

        case "Owl":
            wingSize = int.Parse(args[3]);
            animal   = new Owl(name, weight, wingSize);
            break;

        case "Hen":
            wingSize = int.Parse(args[3]);
            animal   = new Hen(name, weight, wingSize);
            break;
        }

        return(animal);
    }
Exemplo n.º 8
0
        private static Animal ParseAnimal(string input)
        {
            string[] animalTokens = input.Split();
            string   animalType   = animalTokens[0];
            string   name         = animalTokens[1];
            double   weight       = double.Parse(animalTokens[2]);
            string   thirdToken   = animalTokens[3];
            Animal   animal       = null;

            switch (animalType)
            {
            case "Cat":
                string catBreed = animalTokens[4];
                animal = new Cat(name, weight, thirdToken, catBreed);
                break;

            case "Tiger":
                string tigerBreed = animalTokens[4];
                animal = new Tiger(name, weight, thirdToken, tigerBreed);
                break;

            case "Dog":
                animal = new Dog(name, weight, thirdToken);
                break;

            case "Mouse":
                animal = new Mouse(name, weight, thirdToken);
                break;

            case "Owl":
                double owlWingSize = double.Parse(thirdToken);
                animal = new Owl(name, weight, owlWingSize);
                break;

            case "Hen":
                double henWingSize = double.Parse(thirdToken);
                animal = new Hen(name, weight, henWingSize);
                break;

            default:
                throw new ArgumentException("Invalid animal type!");
            }

            return(animal);
        }
Exemplo n.º 9
0
        private static Animal CreateAnimal(string[] parts)
        {
            string type = parts[0];

            Animal animal = null;

            string name = parts[1];

            double weight = double.Parse(parts[2]);

            if (type == nameof(Hen))
            {
                double wingSize = double.Parse(parts[3]);
                animal = new Hen(name, weight, wingSize);
            }
            else if (type == nameof(Owl))
            {
                double wingSize = double.Parse(parts[3]);
                animal = new Owl(name, weight, wingSize);
            }
            else if (type == nameof(Mouse))
            {
                string livinRegion = parts[3];
                animal = new Mouse(name, weight, livinRegion);
            }
            else if (type == nameof(Dog))
            {
                string livinRegion = parts[3];
                animal = new Dog(name, weight, livinRegion);
            }
            else if (type == nameof(Cat))
            {
                string livinRegion = parts[3];
                string breed       = parts[4];
                animal = new Cat(name, weight, livinRegion, breed);
            }
            else if (type == nameof(Tiger))
            {
                string livinRegion = parts[3];
                string breed       = parts[4];
                animal = new Tiger(name, weight, livinRegion, breed);
            }

            return(animal);
        }
Exemplo n.º 10
0
    private static Animal SetAnimal(string[] animalInput)
    {
        var name   = animalInput[1];
        var weight = double.Parse(animalInput[2]);

        Animal animal;

        switch (animalInput[0])
        {
        case "Owl":
            var wingSize = double.Parse(animalInput[3]);

            return(animal = new Owl(name, weight, wingSize));

        case "Hen":
            wingSize = double.Parse(animalInput[3]);

            return(animal = new Hen(name, weight, wingSize));

        case "Mouse":
            var livingRegion = animalInput[3];

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

        case "Dog":
            livingRegion = animalInput[3];

            return(animal = new Dog(name, weight, livingRegion));

        case "Cat":
            livingRegion = animalInput[3];
            var breed = animalInput[4];

            return(animal = new Cat(name, weight, livingRegion, breed));

        case "Tiger":
            livingRegion = animalInput[3];
            breed        = animalInput[4];

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

        default:
            throw new ArgumentException("Wrong Animal!");
        }
    }
Exemplo n.º 11
0
        public void CanInherit()
        {
            Bat      testBat     = new Bat();
            Crow     testCrow    = new Crow();
            Dolphin  testDolphin = new Dolphin();
            Owl      testOwl     = new Owl();
            Penguin  testPenguin = new Penguin();
            SeaOtter testOtter   = new SeaOtter();
            Snake    testSnake   = new Snake();

            Assert.False(testBat.Extinct);
            Assert.False(testCrow.WarmBlooded);
            Assert.True(testDolphin.LiveBirth);
            Assert.True(testOwl.LaysEggs);
            Assert.False(testPenguin.Dangerous);
            Assert.True(testOtter.HasLegs);
            Assert.True(testSnake.ForkedTongue);
        }
        public Animal ProduceBirds(string type, string name, double weight, double wingsize)
        {
            Animal animal = null;

            if (type == "Owl")
            {
                animal = new Owl(name, weight, wingsize);
            }
            else if (type == "Hen")
            {
                animal = new Hen(name, weight, wingsize);
            }
            if (animal == null)
            {
                throw new Exception();
            }
            return(animal);
        }
Exemplo n.º 13
0
    void GetPartTexures()
    {
        //init jsonpath
        jsonPaths.Add(@"Json/body");
        jsonPaths.Add(@"Json/leftwing");
        jsonPaths.Add(@"Json/rightwing");
        jsonPaths.Add(@"Json/leftleg");
        jsonPaths.Add(@"Json/rightleg");

        owl = new Owl(tex, jsonPaths);

        //init partTexList
        partTexList.Add(owl.body.texture);
        partTexList.Add(owl.leftWing.texture);
        partTexList.Add(owl.rightWing.texture);
        partTexList.Add(owl.leftLeg.texture);
        partTexList.Add(owl.rightLeg.texture);
    }
Exemplo n.º 14
0
    private void SortSpeciesName(List <Animal> list)
    {
        Sort(zAnimal);
        Console.WriteLine("Pick the species you want to sort by: Tiger, Elephant or Owl.");
        string input = Console.ReadLine().ToLower();
        int    count = 0;

        if (input == "owl")
        {
            foreach (Animal anim in zAnimal)
            {
                if (anim is Owl)
                {
                    Owl temp = anim as Owl;
                    Console.WriteLine("ID: " + zAnimal[count].Id + ", Species: " + zAnimal[count] + ", Name: " + zAnimal[count].Name + ", Weight: " + zAnimal[count].Weight + ", Age: " + zAnimal[count].Age + ", Wingspan: " + temp.Wingspan + "cm");
                }
                count++;
            }
        }
        if (input == "tiger")
        {
            foreach (Animal anim in zAnimal)
            {
                if (anim is Tiger)
                {
                    Tiger temp = anim as Tiger;
                    Console.WriteLine("ID: " + zAnimal[count].Id + ", Species: " + zAnimal[count] + ", Name: " + zAnimal[count].Name + ", Weight: " + zAnimal[count].Weight + ", Age: " + zAnimal[count].Age);
                }
                count++;
            }
        }
        if (input == "elephant")
        {
            foreach (Animal anim in zAnimal)
            {
                if (anim is Elephant)
                {
                    Elephant temp = anim as Elephant;
                    Console.WriteLine("ID: " + zAnimal[count].Id + ", Species: " + zAnimal[count] + ", Name: " + zAnimal[count].Name + ", Weight: " + zAnimal[count].Weight + ", Age: " + zAnimal[count].Age + ", Trunk length: " + temp.TrunkLength + "cm");
                }
                count++;
            }
        }
    }
Exemplo n.º 15
0
    public static Animal GetAnimal(string[] animalParams)
    {
        Animal animal = null;

        string type         = animalParams[0];
        string name         = animalParams[1];
        double weight       = double.Parse(animalParams[2]);
        double wingSize     = 0;
        string livingRegion = animalParams[3];
        string breed        = null;

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

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

        case "Mouse":
            animal = new Mouse(name, weight, livingRegion);
            break;

        case "Dog":
            animal = new Dog(name, weight, livingRegion);
            break;

        case "Cat":
            breed  = animalParams[4];
            animal = new Cat(name, weight, livingRegion, breed);
            break;

        case "Tiger":
            breed  = animalParams[4];
            animal = new Tiger(name, weight, livingRegion, breed);
            break;
        }

        return(animal);
    }
Exemplo n.º 16
0
        public void InterfacesCanImplement()
        {
            Bat      testBat     = new Bat();
            Crow     testCrow    = new Crow();
            Dolphin  testDolphin = new Dolphin();
            Owl      testOwl     = new Owl();
            Penguin  testPenguin = new Penguin();
            SeaOtter testOtter   = new SeaOtter();
            Snake    testSnake   = new Snake();

            Assert.True(testBat.Fly());
            Assert.True(testCrow.Fly());
            Assert.True(testDolphin.Carnivore());
            Assert.True(testOwl.Fly());
            Assert.True(testPenguin.Carnivore());
            Assert.True(testOtter.Carnivore());
            Assert.True(testSnake.Carnivore());
            Assert.True(testOwl.Carnivore());
        }
Exemplo n.º 17
0
        public Animal CreateAnimal(string[] args)
        {
            Animal current = null;

            if (args.Length == 5)
            {
                if (args[0] == "Cat")
                {
                    current = new Cat(args[1], double.Parse(args[2]), args[3], args[4]);
                }
                else if (args[0] == "Tiger")
                {
                    current = new Tiger(args[1], double.Parse(args[2]), args[3], args[4]);
                }
            }
            else if (args.Length == 4)
            {
                if (args[0] == "Owl" || args[0] == "Hen")
                {
                    if (args[0] == "Owl")
                    {
                        current = new Owl(args[1], double.Parse(args[2]), double.Parse(args[3]));
                    }
                    else if (args[0] == "Hen")
                    {
                        current = new Hen(args[1], double.Parse(args[2]), double.Parse(args[3]));
                    }
                }
                else if (args[0] == "Mouse" || args[0] == "Dog")
                {
                    if (args[0] == "Mouse")
                    {
                        current = new Mouse(args[1], double.Parse(args[2]), args[3]);
                    }
                    else if (args[0] == "Dog")
                    {
                        current = new Dog(args[1], double.Parse(args[2]), args[3]);
                    }
                }
            }

            return(current);
        }
Exemplo n.º 18
0
        private Animal AnimalFactory(string line)
        {
            string[] arg    = line.Split(" ", StringSplitOptions.RemoveEmptyEntries);
            string   type   = arg[0];
            string   name   = arg[1];
            double   weight = double.Parse(arg[2]);
            Animal   animal = null;

            if (type == "Owl")
            {
                double wingSize = double.Parse(arg[3]);
                animal = new Owl(name, weight, wingSize);
            }
            else if (type == "Hen")
            {
                double wingSize = double.Parse(arg[3]);
                animal = new Hen(name, weight, wingSize);
            }
            else if (type == "Mouse")
            {
                string livingRegiom = arg[3];
                animal = new Mouse(name, weight, livingRegiom);
            }
            else if (type == "Dog")
            {
                string livingRegiom = arg[3];
                animal = new Dog(name, weight, livingRegiom);
            }
            else if (type == "Cat")
            {
                string livingRegiom = arg[3];
                string breed        = arg[4];
                animal = new Cat(name, weight, livingRegiom, breed);
            }
            else if (type == "Tiger")
            {
                string livingRegiom = arg[3];
                string breed        = arg[4];
                animal = new Tiger(name, weight, livingRegiom, breed);
            }
            this.animalData.Add(animal);
            return(animal);
        }
Exemplo n.º 19
0
        private Animal GetAnimal(string command)
        {
            string[] animalsArgs = command.Split().ToArray();
            string   type        = animalsArgs[0];
            string   name        = animalsArgs[1];
            double   weight      = double.Parse(animalsArgs[2]);
            Animal   animal      = null;

            if (type == "Owl")
            {
                double wingsize = double.Parse(animalsArgs[3]);
                animal = new Owl(name, weight, wingsize);
            }
            else if (type == "Hen")
            {
                double wingsize = double.Parse(animalsArgs[3]);
                animal = new Hen(name, weight, wingsize);
            }
            else if (type == "Mouse")
            {
                string region = animalsArgs[3];
                animal = new Mouse(name, weight, region);
            }
            else if (type == "Dog")
            {
                string region = animalsArgs[3];
                animal = new Dog(name, weight, region);
            }
            else if (type == "Cat")
            {
                //Tiger Typcho 167.7 Asia Bengal
                string region = animalsArgs[3];
                string breed  = animalsArgs[4];
                animal = new Cat(name, weight, region, breed);
            }
            else if (type == "Tiger")
            {
                string region = animalsArgs[3];
                string breed  = animalsArgs[4];
                animal = new Tiger(name, weight, region, breed);
            }
            return(animal);
        }
Exemplo n.º 20
0
        private IAnimal CreateAnimal(string[] animalInfo)
        {
            var type   = animalInfo[0];
            var name   = animalInfo[1];
            var weight = double.Parse(animalInfo[2]);

            IAnimal animal = null;

            if (type == "Owl")
            {
                var wingSize = double.Parse(animalInfo[3]);
                animal = new Owl(name, weight, wingSize);
            }
            else if (type == "Hen")
            {
                var wingSize = double.Parse(animalInfo[3]);
                animal = new Hen(name, weight, wingSize);
            }
            else if (type == "Mouse")
            {
                var livingRegion = animalInfo[3];
                animal = new Mouse(name, weight, livingRegion);
            }
            else if (type == "Dog")
            {
                var livingRegion = animalInfo[3];
                animal = new Dog(name, weight, livingRegion);
            }
            else if (type == "Cat")
            {
                var livingRegion = animalInfo[3];
                var breed        = animalInfo[4];
                animal = new Cat(name, weight, livingRegion, breed);
            }
            else if (type == "Tiger")
            {
                var livingRegion = animalInfo[3];
                var breed        = animalInfo[4];
                animal = new Tiger(name, weight, livingRegion, breed);
            }

            return(animal);
        }
Exemplo n.º 21
0
        private List <Owl> GetOwls(string where, Dictionary <string, object> param)
        {
            List <Owl> result = new List <Owl>();

            DataTable dt = GetQuery(string.Format("SELECT * FROM Owl {0}", where), param);

            foreach (DataRow dr in dt.Rows)
            {
                Owl temp = new Owl();
                temp.Id                = int.Parse(dr["Id"].ToString());
                temp.UserId            = int.Parse(dr["UserId"].ToString());
                temp.OwlConversationId = int.Parse(dr["OwlConversationId"].ToString());
                temp.Sent              = DateTime.Parse(dr["Sent"].ToString());
                temp.Content           = dr["Content"].ToString();

                result.Add(temp);
            }

            return(result);
        }
Exemplo n.º 22
0
        public override bool Equals(object obj)
        {
            Owl newOwl = obj as Owl;// Если можно преобразовать к стеку, то преобразовывает, если нет становится null

            if (newOwl == null)
            {
                return(false);
            }
            else
            {
                if (id == newOwl.id)
                {
                    return(true);                //Если совпадает ид, то объекты равны
                }
                else
                {
                    return(false);
                }
            }
        }
Exemplo n.º 23
0
        private static IAnimal ProduseAnimal(string[] animalArgs, string animalType, string name, double weight)
        {
            IAnimal animal = null;

            if (animalType == "Owl")
            {
                var wingSize = double.Parse(animalArgs[3]);
                animal = new Owl(name, weight, wingSize);
            }
            else if (animalType == "Hen")
            {
                var wingSize = double.Parse(animalArgs[3]);
                animal = new Hen(name, weight, wingSize);
            }
            else
            {
                var leivingRegion = animalArgs[3];
                if (animalType == "Dog")
                {
                    animal = new Dog(name, weight, leivingRegion);
                }
                else if (animalType == "Mouse")
                {
                    animal = new Mouse(name, weight, leivingRegion);
                }
                else
                {
                    var breed = animalArgs[4];
                    if (animalType == "Cat")
                    {
                        animal = new Cat(name, weight, leivingRegion, breed);
                    }
                    else if (animalType == "Tiger")
                    {
                        animal = new Tiger(name, weight, leivingRegion, breed);
                    }
                }
            }

            return(animal);
        }
Exemplo n.º 24
0
        private static void CreateBird(string[] splitInput)
        {
            string name     = splitInput[1];
            double weight   = double.Parse(splitInput[2]);
            double wingSize = double.Parse(splitInput[3]);

            switch (splitInput[0].ToLower())
            {
            case "hen":
                Hen hen = new Hen(name, weight, 0, wingSize);
                animals.Add(hen);
                hen.ProduceSound();
                break;

            case "owl":
                Owl owl = new Owl(name, weight, 0, wingSize);
                animals.Add(owl);
                owl.ProduceSound();
                break;
            }
        }
Exemplo n.º 25
0
        private static Animal CreateAnimal(List <Animal> animals, string[] animalTokens, string type, string name, double weight, Animal newAnimal)
        {
            switch (type)
            {
            case "Hen":
                newAnimal = new Hen(name, weight, double.Parse(animalTokens[3]));
                animals.Add(newAnimal);
                break;

            case "Owl":
                newAnimal = new Owl(name, weight, double.Parse(animalTokens[3]));
                animals.Add(newAnimal);
                break;

            case "Dog":
                newAnimal = new Dog(name, weight, animalTokens[3]);
                animals.Add(newAnimal);
                break;

            case "Mouse":
                newAnimal = new Mouse(name, weight, animalTokens[3]);
                animals.Add(newAnimal);
                break;

            case "Cat":
                newAnimal = new Cat(name, weight, animalTokens[3], animalTokens[4]);
                animals.Add(newAnimal);
                break;

            case "Tiger":
                newAnimal = new Tiger(name, weight, animalTokens[3], animalTokens[4]);
                animals.Add(newAnimal);
                break;

            default:
                break;
            }

            return(newAnimal);
        }
Exemplo n.º 26
0
    private static Animal GetAnimal(string[] tokens)
    {
        string type   = tokens[0];
        string name   = tokens[1];
        double weight = double.Parse(tokens[2]);
        Animal animal = null;

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

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

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

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

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

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

        default:
            Console.WriteLine("Invalid type");
            break;
        }

        return(animal);
    }
Exemplo n.º 27
0
        public static Animal Create(string[] args)
        {
            string type   = args[0];
            string name   = args[1];
            double weight = double.Parse(args[2]);

            Animal animal = null;

            if (type == "Owl")
            {
                animal = new Owl(name, weight, double.Parse(args[3]));
            }
            else if (type == "Hen")
            {
                animal = new Hen(name, weight, double.Parse(args[3]));
            }
            else if (type == "Cat")
            {
                animal = new Cat(name, weight, args[3], args[4]);
            }
            else if (type == "Tiger")
            {
                animal = new Tiger(name, weight, args[3], args[4]);
            }
            else if (type == "Dog")
            {
                animal = new Dog(name, weight, args[3]);
            }
            else if (type == "Mouse")
            {
                animal = new Mouse(name, weight, args[3]);
            }
            else if (animal == null)
            {
                throw new ArgumentException(String.Format(ExceptionHandling.INVALID_FOOD_TYPE, type));
            }

            return(animal);
        }
Exemplo n.º 28
0
        public int CreateOwl(Owl owl, OwlConversation conversation)
        {
            try
            {
                MySqlCommand cmd = BeginTransaction();

                int result = CreateOwl(cmd, owl);

                foreach (int userId in conversation.UserIds.Where(x => x != owl.UserId))
                {
                    CreateConversationMustRead(cmd, conversation.Id, userId);
                }

                Commit(cmd);

                return(result);
            }
            catch
            {
                return(-1);
            }
        }
Exemplo n.º 29
0
        private Animal CreateAnimal(string type, string[] info)
        {
            Animal animal = null;

            if (type == "Hen")
            {
                double wingSize = double.Parse(info[3]);
                animal = new Hen(info[1], double.Parse(info[2]), wingSize);
            }
            else if (type == "Owl")
            {
                double wingSize = double.Parse(info[3]);
                animal = new Owl(info[1], double.Parse(info[2]), wingSize);
            }
            else if (type == "Mouse")
            {
                string region = info[3];
                animal = new Mouse(info[1], double.Parse(info[2]), region);
            }
            else if (type == "Dog")
            {
                string region = info[3];
                animal = new Dog(info[1], double.Parse(info[2]), region);
            }
            else if (type == "Cat")
            {
                string region = info[3];
                string breed  = info[4];
                animal = new Cat(info[1], double.Parse(info[2]), region, breed);
            }
            else if (type == "Tiger")
            {
                string region = info[3];
                string breed  = info[4];
                animal = new Tiger(info[1], double.Parse(info[2]), region, breed);
            }

            return(animal);
        }
Exemplo n.º 30
0
        public static Animal CreateAnimal(string[] animalData)
        {
            Animal animal       = null;
            string animalType   = animalData[0];
            string animalName   = animalData[1];
            double animalWeight = double.Parse(animalData[2]);

            if (animalType == "Owl" || animalType == "Hen")
            {
                double wingSize = double.Parse(animalData[3]);
                if (animalType == "Owl")
                {
                    return(animal = new Owl(animalName, animalWeight, wingSize));
                }
                return(animal = new Hen(animalName, animalWeight, wingSize));
            }
            else if (animalType == "Dog" || animalType == "Mouse")
            {
                string livingRegion = animalData[3];
                if (animalType == "Dog")
                {
                    return(animal = new Dog(animalName, animalWeight, livingRegion));
                }
                return(animal = new Mouse(animalName, animalWeight, livingRegion));
            }
            else if (animalType == "Cat" || animalType == "Tiger")
            {
                string livingRegion = animalData[3];
                string breed        = animalData[4];

                if (animalType == "Cat")
                {
                    return(animal = new Cat(animalName, animalWeight, livingRegion, breed));
                }
                return(animal = new Tiger(animalName, animalWeight, livingRegion, breed));
            }
            return(animal);
        }
Exemplo n.º 31
0
        private IAnimal GetAnimal(string command)
        {
            string[] animalArgs = command.Split(" ").ToArray();

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

            IAnimal 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[4]);
                animal = new Hen(name, weight, wingSize);
            }
            else
            {
                string livingregion = animalArgs[4];

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