public override void Execute()
        {
            string name = this.Data[0];

            ICleansingCenter cleansingCenter = new CleansingCenter(name);

            this.Database.AddCleasingCenter(cleansingCenter);
        }
Exemple #2
0
        public void RegisterCleansingCenter(string name)
        {
            CleansingCenter cleansingCenter = new CleansingCenter(name);

            if (!this.cleansingCenter.ContainsKey(name))
            {
                this.cleansingCenter.Add(name, cleansingCenter);
            }
        }
    static void Main()
    {
        string input;
        var    centers = new List <Center>();
        var    animals = new List <Animal>();

        while ((input = Console.ReadLine()) != "Paw Paw Pawah")
        {
            var args = input
                       .Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
                       .Select(w => w.Trim())
                       .ToArray();

            var command = args[0];

            switch (command)
            {
            case "RegisterCleansingCenter":
                var newCleansingCenter = new CleansingCenter(args[1]);
                centers.Add(newCleansingCenter);
                break;

            case "RegisterAdoptionCenter":
                var newAdoptionCenter = new AdoptionCenter(args[1]);
                centers.Add(newAdoptionCenter);
                break;

            case "RegisterDog":
                RegisterDogCommand(args, centers);
                break;

            case "RegisterCat":
                RegisterCatCommand(args, centers);
                break;

            case "SendForCleansing":
                SendForCleansingCommand(args, centers);
                break;

            case "Cleanse":
                CleanseAnimalsCommand(args, centers);
                break;

            case "Adopt":
                AdoptAnimalsCommand(args, centers);
                break;

            default:
                throw new ArgumentException();
            }
        }
        Console.WriteLine();
        PrintResult(centers);
    }
Exemple #4
0
        public void Cleanse(CleansingCenter nameCleanse)
        {
            List <Animal> CleanseAnimals = base.animals.
                                           Where(an => an.IsCleaned == false).ToList();

            nameCleanse.AcceptAnimals(CleanseAnimals);
            //double check
            foreach (var animal in CleanseAnimals)
            {
                base.animals.Remove(animal);
            }
        }
Exemple #5
0
        public void SendForCleansing(string[] arr)
        {
            string adoptionCenterName  = arr[1];
            string cleansingCenterName = arr[2];

            AdoptionCenter CurrAdoptionCenter = this.AdoptionCenterlis.
                                                Where(se => se.SeeName() == adoptionCenterName).First();
            CleansingCenter CurrCleansingCenter = this.CleansingCenterlis.
                                                  Where(se => se.SeeName() == cleansingCenterName).First();

            CurrAdoptionCenter.Cleanse(CurrCleansingCenter);
        }
Exemple #6
0
        public void SendForCleansing(string adoptionCenterName, string cleansingCenterName)
        {
            AdoptionCenter adoptionCenter =
                this.adoptionCenter[adoptionCenterName];
            CleansingCenter cleansingCenter =
                this.cleansingCenter[cleansingCenterName];

            if (adoptionCenter == null || cleansingCenter == null)
            {
                throw new ArgumentException("No such Center!");
            }
            adoptionCenter.SenForCleaning(cleansingCenter);
            //    this.adoptionCenter[adoptionCenterName]
            //        .SenForCleaning(this.cleansingCenter[cleansingCenterName]);
        }
Exemple #7
0
        public void Cleanse(string[] arr)
        {
            string          cleansingCenterName = arr[1];
            CleansingCenter CurrCleansingCenter = this.CleansingCenterlis.
                                                  Where(se => se.SeeName() == cleansingCenterName).First();

            CurrCleansingCenter.Cleanse();
            AllCleansedAnimals = CurrCleansingCenter.animals.Select(se => se.Name).ToList();
            foreach (var animal in CurrCleansingCenter.animals)
            {
                AdoptionCenter curr = AdoptionCenterlis.
                                      Where(se => se.SeeName() == animal.DefCenter).First();
                curr.AddAnimal(animal);
            }
        }
Exemple #8
0
    public void SendForClean(CleansingCenter cleanseCenter)
    {
        if (this.StoredAnimals.Count() > 0)
        {
            (cleanseCenter.StoredAnimals as List <Animal>).AddRange(this.StoredAnimals.Where(a => a.CleansingStatus == "UNCLEANSED"));

            for (int index = 0; index < this.StoredAnimals.Count(); index++)
            {
                Animal current = (this.StoredAnimals as List <Animal>)[index];

                if (current.CleansingStatus == "UNCLEANSED")
                {
                    (this.StoredAnimals as List <Animal>).RemoveAt(index);
                    index--;
                }
            }
        }
    }
Exemple #9
0
    public void RegisterCleansingCenter(string name)
    {
        CleansingCenter cleansingCenter = new CleansingCenter(name);

        cleansingCenters.Add(cleansingCenter);
    }
    public void RegisterCleansingCenter(string name)
    {
        CleansingCenter current = new CleansingCenter(name);

        this.CleansingCenters[name] = current;
    }
        // register cleansing center with provided adoption center name

        public void RegisterCleansingCenter(string cleansingCenterName)
        {
            var cleansingCenter = new CleansingCenter(cleansingCenterName);

            cleansingCenters.Add(cleansingCenter);
        }
    public static void Execute()
    {
        while (true)
        {
            string[] commandArgs = Console.ReadLine().Split(new string[] { " | " }, StringSplitOptions.RemoveEmptyEntries);
            string   command     = commandArgs[0];
            switch (command)
            {
            case "RegisterCastrationCenter":
                string centerName = commandArgs[1];
                castrationCenters.Add(new CastrationCenter(centerName));
                break;

            case "RegisterCleansingCenter":
                centerName = commandArgs[1];
                cleansingCenters.Add(new CleansingCenter(centerName));
                break;

            case "RegisterAdoptionCenter":
                centerName = commandArgs[1];
                adoptionCenters.Add(new AdoptionCenter(centerName));
                break;

            case "RegisterDog":
                IAnimal dog = null;
                try
                {
                    dog = AnimalFactory.CreateAnimal("Dog", commandArgs[1], commandArgs[2], commandArgs[3]);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    continue;
                }
                string adoadoptionCenterName = commandArgs[4];

                AdoptionCenter center = adoptionCenters.FirstOrDefault(c => c.Name == adoadoptionCenterName);

                center.AddAnimal(dog);

                break;

            case "RegisterCat":
                IAnimal cat = null;
                try
                {
                    cat = AnimalFactory.CreateAnimal("Cat", commandArgs[1], commandArgs[2], commandArgs[3]);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                adoadoptionCenterName = commandArgs[4];

                center = adoptionCenters.FirstOrDefault(c => c.Name == adoadoptionCenterName);

                center.AddAnimal(cat);
                break;

            case "SendForCleansing":
                adoadoptionCenterName = commandArgs[1];
                string cleansingCenterName = commandArgs[2];

                AdoptionCenter  adoadoptionCenter = adoptionCenters.FirstOrDefault(c => c.Name == adoadoptionCenterName);
                CleansingCenter cleansingCenter   = cleansingCenters.FirstOrDefault(c => c.Name == cleansingCenterName);

                cleansingCenter.AddAnimalsFromAdoptionCenter(adoadoptionCenter.SendForCleansing());
                break;

            case "SendForCastration":
                adoadoptionCenterName = commandArgs[1];
                string castrationCenterName = commandArgs[2];

                adoadoptionCenter = adoptionCenters.FirstOrDefault(c => c.Name == adoadoptionCenterName);

                CastrationCenter castrationCenter = castrationCenters.FirstOrDefault(c => c.Name == castrationCenterName);

                castrationCenter.AddAnimalsFromAdoptionCenter(adoadoptionCenter.SendForCastration());
                break;

            case "Cleanse":
                cleansingCenterName = commandArgs[1];
                cleansingCenter     = cleansingCenters.FirstOrDefault(c => c.Name == cleansingCenterName);

                var centerAndAnimals = cleansingCenter.Cleanse();

                foreach (var pair in centerAndAnimals)
                {
                    adoadoptionCenterName = pair.Key;
                    adoadoptionCenter     = adoptionCenters.FirstOrDefault(c => c.Name == adoadoptionCenterName);

                    adoadoptionCenter.AddAnimals(pair.Value);
                }
                break;

            case "Castrate":
                castrationCenterName = commandArgs[1];
                castrationCenter     = castrationCenters.FirstOrDefault(c => c.Name == castrationCenterName);

                centerAndAnimals = castrationCenter.Castrate();

                foreach (var pair in centerAndAnimals)
                {
                    adoadoptionCenterName = pair.Key;
                    adoadoptionCenter     = adoptionCenters.FirstOrDefault(c => c.Name == adoadoptionCenterName);

                    adoadoptionCenter.AddAnimals(pair.Value);
                }
                break;

            case "Adopt":
                adoadoptionCenterName = commandArgs[1];
                adoadoptionCenter     = adoptionCenters.FirstOrDefault(c => c.Name == adoadoptionCenterName);

                adoadoptionCenter.Adopt();
                break;

            case "CastrationStatistics":
                StringBuilder sb = new StringBuilder();

                sb.Append($"Paw Inc. Regular Castration Statistics{Environment.NewLine}");
                sb.Append($"Castration Centers: {castrationCenters.Count}{Environment.NewLine}");

                string castratedAnimals = CastrationCenter.CastratedAnimals.Count == 0 ? "None" : string.Join(", ", CastrationCenter.CastratedAnimals.OrderBy(a => a.Name));
                sb.Append($"Castrated Animals: {castratedAnimals}");

                Console.WriteLine(sb.ToString());
                break;

            case "Paw Paw Pawah":
                sb = new StringBuilder();
                sb.Append($"Paw Incorporative Regular Statistics{Environment.NewLine}");

                sb.Append($"Adoption Centers: {adoptionCenters.Count}{Environment.NewLine}");
                sb.Append($"Cleansing Centers: {cleansingCenters.Count}{Environment.NewLine}");

                string adoptedAnimals = AdoptionCenter.AdoptedAnimals.Count == 0 ? "None" : string.Join(", ", AdoptionCenter.AdoptedAnimals.OrderBy(a => a.Name));
                sb.Append($"Adopted Animals: {adoptedAnimals}{Environment.NewLine}");

                string cleansedAnimals = CleansingCenter.CleansedAnimals.Count == 0 ? "None" : string.Join(", ", CleansingCenter.CleansedAnimals.OrderBy(a => a.Name));
                sb.Append($"Cleansed Animals: {cleansedAnimals}{Environment.NewLine}");

                int amountOfAnimalsWaitingForAdoption = adoptionCenters.Sum(a => a.AnimalsAwaitingAdoption());
                sb.Append($"Animals Awaiting Adoption: {amountOfAnimalsWaitingForAdoption}{Environment.NewLine}");

                int amountOfAnimalsWaitingForCleansing = cleansingCenters.Sum(a => a.AnimalsAwaitingCleansing());
                sb.Append($"Animals Awaiting Cleansing: {amountOfAnimalsWaitingForCleansing}");

                Console.WriteLine(sb.ToString());
                return;
            }
        }
    }
    public void RegisterCleansingCenter(string name)
    {
        CleansingCenter cc = new CleansingCenter(name);

        cleansingCenters.Add(name, cc);
    }
Exemple #14
0
    public static void Start()
    {
        var    adoptet           = new List <string>();
        var    adoptetCentres    = new List <AdoptionCenter>();
        var    clinned           = new List <string>();
        var    clinnedCeneters   = new List <CleansingCenter>();
        var    castrationCenter  = new List <CastrationCenter>();
        var    castrationAnimals = new List <string>();
        string inputLine;

        while ((inputLine = Console.ReadLine()) != "Paw Paw Pawah")
        {
            var    command = inputLine.Split(new string[] { " | " }, StringSplitOptions.RemoveEmptyEntries);
            var    cmdArg  = command[0];
            string name    = null;
            if (command.Length > 1)
            {
                name = command[1];
            }
            switch (cmdArg)
            {
            case "RegisterCleansingCenter": var clining = new CleansingCenter(name);
                clinnedCeneters.Add(clining);
                break;

            case "RegisterAdoptionCenter": var adop = new AdoptionCenter(name);
                adoptetCentres.Add(adop);
                break;

            case "RegisterDog": var dog = new Dog(name, int.Parse(command[2]), int.Parse(command[3]), command[4]);
                adoptetCentres.First(n => n.Name == command[4]).AddAnimal(dog);
                break;

            case "RegisterCat":
                var cat = new Cat(name, int.Parse(command[2]), int.Parse(command[3]), command[4]);
                adoptetCentres.First(n => n.Name == command[4]).AddAnimal(cat);
                break;

            case "SendForCleansing":
                var forClining = adoptetCentres.First(c => c.Name == name);
                var cliniin    = clinnedCeneters.First(c => c.Name == command[2]);
                cliniin.AddForClining(forClining.Animals);
                break;

            case "Cleanse":
                var clin = clinnedCeneters.First(c => c.Name == name);
                foreach (var clinAnimal in clin.Animals)
                {
                    clinned.Add(clinAnimal.Name);
                }
                clin.CliningAnimal();
                break;

            case "Adopt":
                var adopt = adoptetCentres.FirstOrDefault(c => c.Name == name);
                if (adopt != null)
                {
                    foreach (var clinAnimal in adopt.Animals)
                    {
                        if (clinAnimal.Status)
                        {
                            adoptet.Add(clinAnimal.Name);
                        }
                    }
                }
                adopt.Adopt(adoptet);
                break;

            case "RegisterCastrationCenter": var center = new CastrationCenter(name);
                castrationCenter.Add(center);
                break;

            case "SendForCastration": var adoptetCenter = adoptetCentres.FirstOrDefault(c => c.Name == name);
                var centerCast = castrationCenter.FirstOrDefault(c => c.Name == command[2]);
                if (adoptetCenter != null && centerCast != null)
                {
                    centerCast.AddAnimalCastration(adoptetCenter.Animals);
                }
                break;

            case "Castrate": var cst = castrationCenter.First(c => c.Name == name);
                foreach (var cstAnimal in cst.Animals)
                {
                    castrationAnimals.Add(cstAnimal.Name);
                }
                cst.Castration();
                break;

            case "CastrationStatistics": var sbb = new StringBuilder();
                sbb.AppendLine($"Paw Inc. Regular Castration Statistics")
                .AppendLine($"Castration Centers: {castrationCenter.Count}");
                if (castrationAnimals.Count != 0)
                {
                    sbb.AppendLine($"Castrated Animals: {string.Join(", ", castrationAnimals.OrderBy(x => x))}");
                }
                else
                {
                    sbb.AppendLine($"Castrated Animals: None");
                }
                Console.WriteLine(sbb.ToString().Trim());
                break;
            }
        }

        var sb = new StringBuilder();

        sb.AppendLine($"Paw Incorporative Regular Statistics")
        .AppendLine($"Adoption Centers: {adoptetCentres.Count}")
        .AppendLine($"Cleansing Centers: {clinnedCeneters.Count}");
        if (adoptet.Count == 0)
        {
            sb.AppendLine($"Adopted Animals: None");
        }
        else
        {
            sb.AppendLine($"Adopted Animals: {string.Join(", ", adoptet.OrderBy(x => x))}");
        }
        if (clinned.Count == 0)
        {
            sb.AppendLine($"Cleansed Animals: None");
        }
        else
        {
            sb.AppendLine($"Cleansed Animals: {string.Join(", ", clinned.OrderBy(x=>x))}");
        }
        int count = 0;

        foreach (var VARIABLE in adoptetCentres.SelectMany(x => x.Animals))
        {
            if (VARIABLE.Status)
            {
                count++;
            }
        }
        sb.AppendLine($"Animals Awaiting Adoption: {count}");
        int coont = 0;

        foreach (var VARIABLE in clinnedCeneters.SelectMany(x => x.Animals))
        {
            if (!VARIABLE.Status)
            {
                coont++;
            }
        }
        sb.AppendLine($"Animals Awaiting Cleansing: {coont}");
        var result = sb.ToString().Trim();

        Console.WriteLine(result);
    }