Esempio n. 1
0
        public string RegisterBuilding(List <string> args)
        {
            string type        = args[0];
            string name        = args[1];
            string city        = args[2];
            int    stars       = int.Parse(args[3]);
            double rentAmount  = double.Parse(args[4]);
            string companyName = args[5];

            Company company = GetCompanyByName(companyName);

            if (company == null)
            {
                return(string.Format(MissingCompanyMessage, companyName));;
            }

            Building building = company.GetBuildingByName(name);

            if (building != null)
            {
                return($"Building {name} is already registered in {companyName}!");
            }

            switch (type)
            {
            case "Hotel":
                building = new Hotel(name, city, stars, rentAmount);
                break;

            case "Residence":
                building = new Residence(name, city, stars, rentAmount);
                break;

            case "Business":
                building = new Business(name, city, stars, rentAmount);
                break;
            }

            company.AddBuilding(building);

            return($"Building {name} was successfully registerd in {companyName} catalog!");
        }