private List <AnimalStatus> selectCattleStatuses(SqlCommand cmd)
        {
            cmd.CommandType = CommandType.StoredProcedure;
            SqlConnection       con = cmd.Connection;
            List <AnimalStatus> listCattleStatus = new List <AnimalStatus>();

            con.Open();
            using (con)
            {
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    listCattleStatus = new List <AnimalStatus>();
                    while (dr.Read())
                    {
                        string isMilk = Convert.ToString(dr[3]);

                        AnimalStatus status = new AnimalStatus()
                        {
                            ID          = Convert.ToInt32(dr[0]),
                            Description = Convert.ToString(dr[1]),
                            Comments    = Convert.ToString(dr[2])
                        };

                        if (isMilk == "Y")
                        {
                            status.IsMilking = true;
                        }

                        listCattleStatus.Add(status);
                    }
                }
            }
            return(listCattleStatus);
        }
Ejemplo n.º 2
0
 public AbstractAnimal(String name)
 {
     this.name = name;
     this.progressTime = 0;
     this.status = AnimalStatus.Wait;
     this.seed = null;
 }
Ejemplo n.º 3
0
        // Decrease animal status
        public void ChangeStatus()
        {
            if (_status > AnimalStatus.Sick)
            {
                _status--;

                // Print message
                Renderer.PrintMessage($"{Type} {Name} status is decreased to {Status}");
            }
            else
            {
                if (_health > 0)
                {
                    _health--;

                    // Print message
                    Renderer.PrintMessage($"{Type} {Name} health is decreased to {Health}");

                    if (_health == 0)
                    {
                        _status = AnimalStatus.Dead;

                        // Print message
                        Renderer.PrintMessage($"{Type} {Name} dead!!!");
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public PagingResult <Animal> GetAnimals(int page, int pageSize, AnimalStatus animalStatus, string searchString = null, Status?status = null)
        {
            var query = DbSet
                        .Include(animal => animal.Adopter)
                        .Where(animal => animal.Status != Status.Deleted && animal.AnimalStatus == animalStatus);

            if (animalStatus == AnimalStatus.Adopted && !User.IsAdminUser)
            {
                query = query.Where(animal => animal.AdopterId == User.GetUserId());
            }

            if (status != null)
            {
                query = query.Where(animal => animal.Status == status);
            }

            if (!string.IsNullOrEmpty(searchString))
            {
                query = query.Where(animal => animal.Name.ToLower().Contains(searchString.ToLower()) || animal.AnimalType.GetDescription().ToLower().Contains(searchString.ToLower()) || animal.Breed.ToLower().Contains(searchString.ToLower()));
            }

            return(new PagingResult <Animal>()
            {
                Elements = query.OrderByDescending(animal => animal.CreatedAt).Skip((page - 1) * pageSize).Take(pageSize),
                ElementsCount = query.Count()
            });
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Convert Enum AnimalStatus to a string
        /// </summary>
        /// <param name="AnimalStatusID">Enum AnimalStatus</param>
        /// <returns>string version of AnimalStatus to be used with PetFinder API animal status</returns>
        public string AnimalStatusString(AnimalStatus AnimalStatusID)
        {
            string statusString = string.Empty;

            switch (AnimalStatusID)
            {
            case AnimalStatus.Adoptable:
                statusString = "A";
                break;

            case AnimalStatus.Adopted:
                statusString = "X";
                break;

            case AnimalStatus.Hold:
                statusString = "H";
                break;

            case AnimalStatus.Pending:
                statusString = "P";
                break;

            case AnimalStatus.None:
                statusString = string.Empty;
                break;

            default:
                statusString = "A";
                break;
            }
            return(statusString);
        }
Ejemplo n.º 6
0
        public Animal(string name)
        {
            _name   = name;
            _status = AnimalStatus.Full;

            // Print message
            Renderer.PrintMessage($"{Type} {Name} was created");
        }
Ejemplo n.º 7
0
        public PagingResult <Animal> GetAnimals(int page, int pageSize, AnimalStatus animalStatus, string searchString = null, bool?isActive = null)
        {
            Status?status = null;

            if (isActive != null)
            {
                status = isActive.Value ? Status.Active : Status.Inactive;
            }

            return(_repository.GetAnimals(page, pageSize, animalStatus, searchString, status));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Method for getting the string format of the <see cref="AnimalStatus"/>.
        /// </summary>
        /// <param name="status">The status of the animal to ge tthe string format for.</param>
        /// <returns>The string format for the <see cref="AnimalStatus"/>.</returns>
        public static string GetString(this AnimalStatus status)
        {
            var returnResult = string.Empty;

            switch (status)
            {
            case AnimalStatus.Dead:
                returnResult = "Dead";
                break;

            case AnimalStatus.Eating:
                returnResult = "Eating";
                break;

            case AnimalStatus.Hungry:
                returnResult = "Hungry";
                break;

            case AnimalStatus.Starving:
                returnResult = "Starving";
                break;

            case AnimalStatus.Idle:
                returnResult = "Idle";
                break;

            case AnimalStatus.GettingLit:
                returnResult = "Getting lit 😂👌";
                break;

            case AnimalStatus.Playing:
                returnResult = "Playing";
                break;

            case AnimalStatus.Sitting:
                returnResult = "Sitting";
                break;

            case AnimalStatus.SmokeBreak:
                returnResult = "Smoke break";
                break;

            case AnimalStatus.UnableToWalk:
                returnResult = "Unable to walk";
                break;

            case AnimalStatus.Walking:
                returnResult = "Walking";
                break;
            }

            return(returnResult);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Returns a list of IDs or collection of pet records for an individual shelter
        /// </summary>
        /// <param name="animalStatus">optional (default=A, public may only list adoptable pets); A=adoptable, H=hold, P=pending, X=adopted/removed</param>
        /// <param name="offset">offset into the result set (default is 0)</param>
        /// <param name="count">how many records to return for this particular API call (default is 50)</param>
        /// <param name="recordDetail">How much of the pet record to return: id, basic (no description), full</param>
        /// <returns>petfinderPetRecordList</returns>
        public petfinderPetRecordList GetShelterPets(AnimalStatus animalStatus = AnimalStatus.Adoptable, int offset = 0, int count = 50, AnimalRecordDetail recordDetail = AnimalRecordDetail.Full)
        {
            List <KeyValuePair <string, string> > urlParameters = new List <KeyValuePair <string, string> >();

            urlParameters.Add(new KeyValuePair <string, string>("id", PetFinderProcessing.ShelterID));
            urlParameters.Add(new KeyValuePair <string, string>("status", AnimalStatusString(animalStatus)));
            urlParameters.Add(new KeyValuePair <string, string>("offset", offset.ToString()));
            urlParameters.Add(new KeyValuePair <string, string>("count", count.ToString()));
            urlParameters.Add(new KeyValuePair <string, string>("output", AnimalRecuredDetail(recordDetail)));

            petfinder petFinder = SendRequest("shelter.getPets", urlParameters);

            return((petfinderPetRecordList)petFinder.Item);
        }
Ejemplo n.º 10
0
    public void attackAnimal(RaycastHit2D rayHit)
    {
        GameObject   targetGameObject = rayHit.transform.gameObject as GameObject;
        AnimalStatus status           = targetGameObject.GetComponent <AnimalStatus>();

        status.hitAnimal(1);
        if (status.Hp <= 0)
        {
            if (null != targetGameObject.GetComponent <Items>())
            {
                mineItems(rayHit);
            }
            status.Die();
        }
    }
Ejemplo n.º 11
0
        // Feed the animal
        public void Feed()
        {
            if (Status != AnimalStatus.Dead)
            {
                _status = AnimalStatus.Full;

                // Print message
                Renderer.PrintMessage($"{Type} {Name} is feeded, his status: {Status}");
            }
            else
            {
                // Print message
                Renderer.PrintMessage($"{Type} {Name} dead, you can't feed it");
            }
        }
Ejemplo n.º 12
0
    IEnumerator Move()
    {
        isMoving = true;

        for (float t = 0.0f; t < 1.0f; t += Time.deltaTime * speed)
        {
            transform.position = Vector2.MoveTowards(transform.position, targetPos, t);
            AnimalStatus animalStatus = GetComponent <AnimalStatus>();
            animalObserver.sendAnimalDataToServer(animalStatus.Id, transform.position, transform.rotation, ClientAction.ANIMAL, Action.ANIMAL_MOVE);
            yield return(null);
        }

        yield return(new WaitForSeconds(waitTime));

        isMoving = false;
        yield return(null);
    }
Ejemplo n.º 13
0
    public void createNewAnimal(PlayerDefaultDto dto)
    {
        Vector3    pos = dto.positionToVector3();
        Quaternion rot = dto.rotationToQuaternion();

        if (pos.x == 0 && pos.y == 0)
        {
            pos = new Vector3(transform.position.x - Random.Range(1, 10), transform.position.y - Random.Range(1, 15), -20);
            rot = transform.rotation;
        }

        string       newId     = System.Guid.NewGuid().ToString();
        GameObject   newAnimal = Instantiate(prefabs[0], pos, rot);
        AnimalStatus status    = newAnimal.GetComponent <AnimalStatus>();

        status.Id = newId;
        animals.Add(newId, newAnimal);
    }
Ejemplo n.º 14
0
 public void tick()
 {
     if (this.progressTime > 0)
     {
         this.progressTime--;
         if (this.progressTime == 0 && this.status == AnimalStatus.Work && this.finishEvent != null)
         {
             this.finishEvent.finish(this);
             this.seed.stepStatus();
             this.status = AnimalStatus.Rest;
             this.progressTime = this.restTime();
         }
         else if (this.progressTime == 0 && this.status == AnimalStatus.Rest && this.finishEvent != null)
         {
             this.finishEvent.finish(this);
             this.status = AnimalStatus.Wait;
         }
     }
 }
        /// <summary>
        /// Creator: Austin Gee
        /// Created: 3/12/2020
        /// Approver: Michael Thompson
        ///
        /// Inserts a fake animal status
        /// </summary>
        /// <remarks>
        /// Updater: NA
        /// Updated: NA
        /// Update: NA
        ///
        /// </remarks>
        /// <param name="animalID"></param>
        /// <param name="statusID"></param>
        /// <returns></returns>
        public int InsertAnimalStatus(int animalID, string statusID)
        {
            int rows = 0;

            AnimalStatus animalStatus = new AnimalStatus()
            {
                AnimalID = animalID,
                StatusID = statusID
            };

            try
            {
                _animalStatuses.Add(animalStatus);
                rows = 1;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(rows);
        }
Ejemplo n.º 16
0
 public void setAnim()
 {
     AnimalStatus.AnimalPosition = 1;
     AnimalStatus.z1();
 }
Ejemplo n.º 17
0
 // Get list of animals with entered status
 public IEnumerable <Animal> GetAnimalsByStatus(AnimalStatus status)
 {
     return(_animals.Where(animal => animal.Status.Equals(status)));
 }
Ejemplo n.º 18
0
 public AnimalStatusDTO(AnimalStatus animalStatus)
 {
     StatusId      = animalStatus.StatusId;
     AnimalStatus1 = animalStatus.AnimalStatus1;
 }
Ejemplo n.º 19
0
        public void Run()
        {
            bool allAnimalsDead = false;    // Flag to display message
            int  userInput      = 0;        // User input command

            do
            {
                // Check if any animal alive
                var animals = zoo.GetAnimalList();
                if (animals.ToArray().Length > 0)
                {
                    var deadAnimals = animals.Where(i => i.Status.Equals(AnimalStatus.Dead));
                    if (animals.ToArray().Length == deadAnimals.ToArray().Length)
                    {
                        allAnimalsDead = true;
                        break;
                    }
                }

                // Print header
                Renderer.PrintHeader();

                // Print menu
                userInput = Renderer.DisplayMenu("Actions:", new List <string>
                {
                    "1. Add animal",
                    "2. Feed animal",
                    "3. Cure animal",
                    "4. Delete animal",
                    "5. Show animals    <--- 3rd task",
                    "6. Exit"
                });


                // Exit command
                if (userInput == 6)
                {
                    break;
                }

                try
                {
                    // Print header
                    Renderer.PrintHeader();

                    switch (userInput)
                    {
                    case 1:

                        // Print menu
                        userInput = Renderer.DisplayMenu("Choose animal type:", new List <string>
                        {
                            "1. Lion",
                            "2. Tiger",
                            "3. Elephant",
                            "4. Bear",
                            "5. Wolf",
                            "6. Fox",
                            "Press any key back to prev menu"
                        });

                        // Print header
                        Renderer.PrintHeader();

                        switch (userInput)
                        {
                        case 1:
                            Console.WriteLine($"Type lion name to create:");
                            zoo.CreateAnimal(Console.ReadLine(), AnimalType.Lion);
                            break;

                        case 2:
                            Console.WriteLine($"Type tiger name to create:");
                            zoo.CreateAnimal(Console.ReadLine(), AnimalType.Tiger);
                            break;

                        case 3:
                            Console.WriteLine($"Type elephant name to create:");
                            zoo.CreateAnimal(Console.ReadLine(), AnimalType.Elephant);
                            break;

                        case 4:
                            Console.WriteLine($"Type bear name to create:");
                            zoo.CreateAnimal(Console.ReadLine(), AnimalType.Bear);
                            break;

                        case 5:
                            Console.WriteLine($"Type wolf name to create:");
                            zoo.CreateAnimal(Console.ReadLine(), AnimalType.Wolf);
                            break;

                        case 6:
                            Console.WriteLine($"Type fox name to create:");
                            zoo.CreateAnimal(Console.ReadLine(), AnimalType.Fox);
                            break;

                        default:
                            break;
                        }

                        userInput = 0;
                        break;

                    case 2:
                        Console.WriteLine($"Type animal name to feed:");
                        var feedAnimal = zoo.GetAnimalByName(Console.ReadLine());
                        feedAnimal.Feed();
                        break;

                    case 3:
                        Console.WriteLine($"Type animal name to cure:");
                        var cureAnimal = zoo.GetAnimalByName(Console.ReadLine());
                        cureAnimal.Cure();
                        break;

                    case 4:
                        Console.WriteLine($"Type animal name to delete:");
                        zoo.DeleteAnimal(Console.ReadLine());
                        break;

                    case 5:

                        // Print menu
                        userInput = Renderer.DisplayMenu("Show:", new List <string>
                        {
                            "1. Animals grouped by type",
                            "2. Animals by status",
                            "3. All sick tigers",
                            "4. Elephant by name",
                            "5. Names of empty animals",
                            "6. More healthy animals of the each type",
                            "7. Dead animals amount of the each type",
                            "8. Wolfs and bears that have health > 3",
                            "9. Animals that have min and max health",
                            "10. Average health of alive animals",
                            "Press any key back to prev menu"
                        });

                        // Print header
                        Renderer.PrintHeader();

                        switch (userInput)
                        {
                        case 1:

                            Console.WriteLine($"Animals grouped by type:");
                            zoo.GetAnimalsGroupedByType().ToList()
                            .ForEach(g =>
                            {
                                Console.WriteLine($"Group {g.Key}");
                                g.ToList().ForEach(i => Console.WriteLine(i));
                            });

                            Console.ReadKey();
                            break;

                        case 2:

                            // Print menu
                            userInput = Renderer.DisplayMenu("Choose animal status:", new List <string>
                            {
                                "1. Full",
                                "2. Empty",
                                "3. Sick",
                                "4. Dead",
                                "Press any key back to prev menu"
                            });

                            // Print header
                            Renderer.PrintHeader();

                            var status = new AnimalStatus();

                            switch (userInput)
                            {
                            case 1:
                                status = AnimalStatus.Full;
                                break;

                            case 2:
                                status = AnimalStatus.Empty;
                                break;

                            case 3:
                                status = AnimalStatus.Sick;
                                break;

                            case 4:
                                status = AnimalStatus.Dead;
                                break;

                            default:
                                break;
                            }

                            Console.WriteLine($"Animals with selected status:");

                            zoo.GetAnimalsByStatus(status).ToList()
                            .ForEach(i => Console.WriteLine(i));

                            Console.ReadKey();
                            break;

                        case 3:

                            Console.WriteLine($"Sick tigers:");

                            zoo.GetSickTigers().ToList().ForEach(i => Console.WriteLine(i));

                            Console.ReadKey();
                            break;

                        case 4:

                            Console.WriteLine($"Show elephant by name:");

                            Console.WriteLine(zoo.GetElephantByName(Console.ReadLine()));

                            Console.ReadKey();
                            break;

                        case 5:

                            Console.WriteLine($"List of empty animals names:");

                            zoo.GetEmptyAnimalsNames().ToList().ForEach(i => Console.WriteLine(i));

                            Console.ReadKey();
                            break;

                        case 6:

                            Console.WriteLine($"More healthy animals of each type:");

                            zoo.GetMoreHealthyAnimalsEachType().ToList().ForEach(i => Console.WriteLine(i));

                            Console.ReadKey();
                            break;

                        case 7:

                            Console.WriteLine($"Dead animals amount of each group:");

                            zoo.GetDeadAnimalsAmountEachType().ToList().ForEach(i => Console.WriteLine($"{i.Key}: {i.Value}"));

                            Console.ReadKey();
                            break;

                        case 8:

                            Console.WriteLine($"Wolfs and bears that have health greater than 3 points:");

                            zoo.GetWolfsAndBearsHealthGt3().ToList().ForEach(i => Console.WriteLine(i));

                            Console.ReadKey();
                            break;

                        case 9:

                            Console.WriteLine($"Animals that have min and max health:");

                            zoo.GetAnimalsMinMaxHealth().ToList().ForEach(i => Console.WriteLine(i));

                            Console.ReadKey();
                            break;

                        case 10:

                            Console.WriteLine($"Avg health of alive animals:");

                            Console.WriteLine(zoo.GetAnimalsAvgHealth());

                            Console.ReadKey();
                            break;

                        default:
                            break;
                        }

                        userInput = 0;
                        break;

                    default:
                        break;
                    }
                }
                catch (InvalidOperationException)
                {
                    Renderer.PrintMessage("Animal you specify doesn't exist");
                }
            }while (true);

            // Show message if all animals are dead
            if (allAnimalsDead)
            {
                Console.Clear();
                Console.WriteLine("There are any alive animal in the zoo!");
                Console.ReadKey();
            }
        }
Ejemplo n.º 20
0
 protected void startWork(SeedBed seed, int time)
 {
     this.progressTime = time;
     this.status = AnimalStatus.Work;
     this.seed = seed;
 }