private static void PrintClinicRooms(List <Clinic> clinics, List <string> commandArgs)
    {
        Clinic currentClinicPrint = clinics.FirstOrDefault(c => c.Name == commandArgs[1]);

        if (commandArgs.Count == 3)
        {
            Console.WriteLine(currentClinicPrint.PrintRoom(int.Parse(commandArgs[2])));
        }
        else
        {
            Console.WriteLine(currentClinicPrint.PrintAllRooms());
        }
    }
Ejemplo n.º 2
0
    public string Print(params string[] args)
    {
        string clinicName = args[1];

        Clinic clinic = FindClinic(clinicName);

        if (args.Length == 3)
        {
            int roomNumber = int.Parse(args[2]);

            return(clinic.PrintRoom(roomNumber));
        }

        return(clinic.PrintAll());
    }
Ejemplo n.º 3
0
        public void Run()
        {
            var numberOfCommands = int.Parse(Console.ReadLine());

            for (int i = 0; i < numberOfCommands; i++)
            {
                var input = Console.ReadLine().Split();

                var    command = input[0];
                var    name    = string.Empty;
                Clinic clinic  = null;
                Pet    pet     = null;


                switch (command)
                {
                case "Create":
                    if (input.Length > 4)
                    {
                        pet = CreatePet(input);
                        this.pets.Add(pet);
                    }
                    else
                    {
                        clinic = CreateClinic(input);
                        this.clinics.Add(clinic);
                    }
                    break;

                case "Add":
                    var petToAdd = this.pets.
                                   First(p => p.Name == input[1]);

                    clinic = this.clinics.
                             First(c => c.Name == input[2]);

                    Console.WriteLine(clinic.AddPet(petToAdd));
                    break;

                case "Release":
                    clinic = this.clinics.
                             First(c => c.Name == input[1]);

                    Console.WriteLine(clinic.Release());
                    break;

                case "HasEmptyRooms":
                    clinic = this.clinics.
                             First(c => c.Name == input[1]);
                    Console.WriteLine(clinic.HasEmptyRooms());
                    break;

                case "Print":
                    clinic = this.clinics.
                             First(c => c.Name == input[1]);

                    if (input.Length > 2)
                    {
                        var roomID = int.Parse(input[2]);
                        clinic.PrintRoom(roomID);
                    }
                    else
                    {
                        clinic.PrintAllRooms();
                    }
                    break;
                }
            }
        }
Ejemplo n.º 4
0
    private static void Run(string[] input)
    {
        string command = input[0];

        switch (command)
        {
        case "Create":
        {
            string typeOfCreation = input[1];
            if (typeOfCreation == "Pet")
            {
                Pet pet = new Pet(input[2], int.Parse(input[3]), input[4]);
                pets.Add(pet);
            }
            else
            {
                Clinic clinic = new Clinic(input[2], int.Parse(input[3]));

                clinics.Add(clinic);
            }
            break;
        }

        case "Add":
        {
            string petName    = input[1];
            string clinicName = input[2];

            Clinic clinic = clinics.FirstOrDefault(c => c.Name == clinicName);
            Pet    pet    = pets.FirstOrDefault(p => p.Name == petName);
            Console.WriteLine(clinic.AddPet(pet));
            break;
        }

        case "Release":
        {
            string clinicName = input[1];

            Clinic clinic = clinics.FirstOrDefault(c => c.Name == clinicName);
            Console.WriteLine(clinic.ReleasingPet());
            break;
        }

        case "HasEmptyRooms":
        {
            string clinicName = input[1];

            Clinic clinic = clinics.FirstOrDefault(c => c.Name == clinicName);
            Console.WriteLine(clinic.HasEmptyRoom());
            break;
        }

        case "Print":
        {
            string clinicName = input[1];
            Clinic clinic     = clinics.FirstOrDefault(c => c.Name == clinicName);
            if (input.Length == 2)
            {
                Console.WriteLine(clinic.ToString());
            }
            else
            {
                int roomNumber = int.Parse(input[2]);
                Console.WriteLine(clinic.PrintRoom(roomNumber));
            }
            break;
        }
        }
    }
    public static void Main()
    {
        int           numberOfCommands = int.Parse(Console.ReadLine());
        List <Pet>    pets             = new List <Pet>();
        List <Clinic> clinics          = new List <Clinic>();

        for (int i = 0; i < numberOfCommands; i++)
        {
            string[] command = Console.ReadLine().Split();

            switch (command[0])
            {
            case "Create":
                if (command[1] == "Pet")
                {
                    Pet pet = new Pet(command[2], int.Parse(command[3]), command[4]);
                    pets.Add(pet);
                }
                else if (command[1] == "Clinic")
                {
                    int numberOfRooms = int.Parse(command[3]);

                    if (numberOfRooms % 2 == 0)
                    {
                        Console.WriteLine("Invalid Operation!");
                    }
                    else
                    {
                        Clinic clinic = new Clinic(command[2], numberOfRooms);
                        clinics.Add(clinic);
                    }
                }
                break;

            case "Add":
                if (!pets.Any(p => p.Name == command[1]) ||
                    !clinics.Any(c => c.Name == command[2]))
                {
                    Console.WriteLine("Invalid Operation!");
                }
                else
                {
                    Pet    pet    = pets.First(p => p.Name == command[1]);
                    Clinic clinic = clinics.First(c => c.Name == command[2]);
                    Console.WriteLine(clinic.AddPet(pet));
                }
                break;

            case "Release":
                if (!clinics.Any(c => c.Name == command[1]))
                {
                    Console.WriteLine("Invalid Operation!");
                }
                else
                {
                    Clinic clinic = clinics.First(c => c.Name == command[1]);
                    Console.WriteLine(clinic.RemovePet());
                }
                break;

            case "HasEmptyRooms":
                if (!clinics.Any(c => c.Name == command[1]))
                {
                    Console.WriteLine("Invalid Operation!");
                }
                else
                {
                    Clinic clinic = clinics.First(c => c.Name == command[1]);
                    Console.WriteLine(clinic.HasEmptyRooms());
                }
                break;

            case "Print":
                if (!clinics.Any(c => c.Name == command[1]))
                {
                    Console.WriteLine("Invalid Operation!");
                }
                else
                {
                    if (command.Length == 2)
                    {
                        Clinic clinic = clinics.First(c => c.Name == command[1]);
                        Console.Write(clinic.ToString());
                    }
                    else if (command.Length == 3)
                    {
                        Clinic clinic = clinics.First(c => c.Name == command[1]);
                        Console.Write(clinic.PrintRoom(int.Parse(command[2])));
                    }
                }
                break;

            default:
                break;
            }
        }
    }