Example #1
0
        public string Manufacture(string robotType, string name, int energy, int happiness, int procedureTime)
        {
            IRobot robot = null;

            if (robotType == "HouseholdRobot")
            {
                robot = new HouseholdRobot(name, energy, happiness, procedureTime);
            }
            else if (robotType == "PetRobot")
            {
                robot = new PetRobot(name, energy, happiness, procedureTime);
            }
            else if (robotType == "WalkerRobot")
            {
                robot = new WalkerRobot(name, energy, happiness, procedureTime);
            }
            else
            {
                throw new ArgumentException($"{robotType} type doesn't exist");
            }

            Garage.Manufacture(robot);

            return($"Robot {name} registered successfully");
        }
Example #2
0
        public string Manufacture(string robotType, string name, int energy, int happiness, int procedureTime)
        {
            IRobot robot;

            if (robotType == nameof(HouseholdRobot))
            {
                robot = new HouseholdRobot(name, energy, happiness, procedureTime);
            }

            else if (robotType == nameof(PetRobot))
            {
                robot = new PetRobot(name, energy, happiness, procedureTime);
            }

            else if (robotType == nameof(WalkerRobot))
            {
                robot = new WalkerRobot(name, energy, happiness, procedureTime);
            }

            else
            {
                throw new ArgumentException(String.Format(ExceptionMessages.InvalidRobotType, robotType));
            }

            garage.Manufacture(robot);
            return(String.Format(OutputMessages.RobotManufactured, robot.Name));
        }
Example #3
0
        public string Manufacture(string robotType, string name, int energy, int happiness, int procedureTime)
        {
            if (robotType != "HouseholdRobot" && robotType != "PetRobot" && robotType != "WalkerRobot")
            {
                throw new ArgumentException(string.Format(ExceptionMessages.InvalidRobotType, robotType));
            }
            try
            {
                IRobot robot = null;
                switch (robotType)
                {
                case "HouseholdRobot":
                    robot = new HouseholdRobot(name, energy, happiness, procedureTime);
                    break;

                case "PetRobot":
                    robot = new PetRobot(name, energy, happiness, procedureTime);
                    break;

                case "WalkerRobot":
                    robot = new WalkerRobot(name, energy, happiness, procedureTime);
                    break;
                }
                if (robot != null)
                {
                    this.garage.Manufacture(robot);
                }
                return(String.Format(OutputMessages.RobotManufactured, name));
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
        public string Manufacture(string robotTypeName, string name, int energy, int happiness, int procedureTime)
        {
            if (!Enum.TryParse(robotTypeName, out RobotType robotType))
            {
                string msg = string.Format(ExceptionMessages.InvalidRobotType, robotTypeName);
                throw new ArgumentException(msg);
            }

            IRobot robot = null;

            switch (robotType)
            {
            case RobotType.PetRobot:
                robot = new PetRobot(name, energy, happiness, procedureTime);
                break;

            case RobotType.HouseholdRobot:
                robot = new HouseholdRobot(name, energy, happiness, procedureTime);
                break;

            case RobotType.WalkerRobot:
                robot = new WalkerRobot(name, energy, happiness, procedureTime);
                break;
            }

            this.garage.Manufacture(robot);

            string outputMsg = string.Format(OutputMessages.RobotManufactured, name);

            return(outputMsg);
        }
Example #5
0
        public string Manufacture(string robotType, string name, int energy, int happiness, int procedureTime)
        {
            IRobot robot;

            switch (robotType)
            {
            case "HouseholdRobot":
                robot = new HouseholdRobot(name, energy, happiness, procedureTime);
                break;

            case "PetRobot":
                robot = new PetRobot(name, energy, happiness, procedureTime);
                break;

            case "WalkerRobot":
                robot = new WalkerRobot(name, energy, happiness, procedureTime);
                break;

            default:
                throw new ArgumentException($"{robotType} type doesn't exist");
            }

            this.garage.Manufacture(robot);
            return($"Robot {name} registered successfully");
        }
Example #6
0
        public string Manufacture(string robotType, string name, int energy, int happiness, int procedureTime)
        {
            // do not use check method here
            IRobot robot = null;

            switch (robotType)
            {
            case "HouseholdRobot":
                robot = new HouseholdRobot(name, energy, happiness, procedureTime);
                break;

            case "WalkerRobot":
                robot = new WalkerRobot(name, energy, happiness, procedureTime);
                break;

            case "PetRobot":
                robot = new PetRobot(name, energy, happiness, procedureTime);
                break;

            default:
                throw new ArgumentException
                          (String.Format(ExceptionMessages.InvalidRobotType, robotType));
            }

            garage.Manufacture(robot);
            return(String.Format(OutputMessages.RobotManufactured, name));
        }
Example #7
0
        public string Manufacture(string robotType, string name, int energy, int happiness, int procedureTime)
        {
            IRobot robot = null;

            if (robotType != "HouseholdRobot" && robotType != "PetRobot" && robotType != "WalkerRobot")
            {
                throw new ArgumentException(string.Format(ExceptionMessages.InvalidRobotType, robotType));
            }

            else if (robotType == "HouseholdRobot")
            {
                robot = new HouseholdRobot(name, energy, happiness, procedureTime);
            }
            else if (robotType == "PetRobot")
            {
                robot = new PetRobot(name, energy, happiness, procedureTime);
            }
            else if (robotType == "WalkerRobot")
            {
                robot = new WalkerRobot(name, energy, happiness, procedureTime);
            }
            garage.Manufacture(robot);



            return($"Robot {robot.Name} registered successfully");
        }
Example #8
0
        public string Manufacture(string robotType, string name, int energy, int happiness, int procedureTime)
        {
            if (!this._validRobotTypes.Contains(robotType))
            {
                string msg = string.Format(ExceptionMessages.InvalidRobotType, robotType);

                throw new ArgumentException(msg);
            }

            IRobot currentRobot = null;

            switch (robotType)
            {
            case "HouseholdRobot":
                currentRobot = new HouseholdRobot(name, energy, happiness, procedureTime);

                break;

            case "WalkerRobot":
                currentRobot = new WalkerRobot(name, energy, happiness, procedureTime);

                break;

            case "PetRobot":
                currentRobot = new PetRobot(name, energy, happiness, procedureTime);

                break;
            }

            this._garage.Manufacture(currentRobot);

            return($"Robot {currentRobot.Name} registered successfully");
        }
Example #9
0
        public string Manufacture(string robotType, string name, int energy, int happiness, int procedureTime)
        {
            if (robotType != nameof(PetRobot) && robotType != nameof(HouseholdRobot) && robotType != nameof(WalkerRobot))
            {
                string msg = String.Format(ExceptionMessages.InvalidRobotType, robotType);
                throw new ArgumentException(msg);
            }

            IRobot robot = null;

            switch (robotType)
            {
            case nameof(PetRobot):
                robot = new PetRobot(name, energy, happiness, procedureTime);
                break;

            case nameof(HouseholdRobot):
                robot = new HouseholdRobot(name, energy, happiness, procedureTime);
                break;

            case nameof(WalkerRobot):
                robot = new WalkerRobot(name, energy, happiness, procedureTime);
                break;
            }

            garage.Manufacture(robot);
            string message = String.Format(OutputMessages.RobotManufactured, name);

            return(message);
        }
        public string Manufacture(string robotType, string name, int energy, int happiness, int procedureTime)
        {
            IRobot robot;

            if (robotType == "HouseholdRobot")
            {
                robot = new HouseholdRobot(name, energy, happiness, procedureTime);
            }
            else if (robotType == "PetRobot")
            {
                robot = new PetRobot(name, energy, happiness, procedureTime);
            }
            else if (robotType == "WalkerRobot")
            {
                robot = new WalkerRobot(name, energy, happiness, procedureTime);
            }
            else
            {
                var exMsg = String.Format(ExceptionMessages.InvalidRobotType, robotType);
                throw new ArgumentException(exMsg);
            }

            this.garage.Manufacture(robot);
            var result = String.Format(OutputMessages.RobotManufactured, name);

            return(result);
        }
Example #11
0
        public string Manufacture(string robotType, string name, int energy, int happiness, int procedureTime)
        {
            if (!(robotType == nameof(HouseholdRobot) || robotType == nameof(PetRobot) || robotType == nameof(WalkerRobot)))
            {
                string msg = string.Format(ExceptionMessages.InvalidRobotType, robotType);

                throw new ArgumentException(msg);
            }

            IRobot robot = null;

            if (robotType == "HouseholdRobot")
            {
                robot = new HouseholdRobot(name, energy, happiness, procedureTime);
            }
            else if (robotType == "PetRobot")
            {
                robot = new PetRobot(name, energy, happiness, procedureTime);
            }
            else if (robotType == "WalkerRobot")
            {
                robot = new WalkerRobot(name, energy, happiness, procedureTime);
            }

            this.garage.Manufacture(robot);

            string outputmsg = string.Format(OutputMessages.RobotManufactured, name);

            return(outputmsg);
        }
        public string Manufacture(string robotType, string name, int energy, int happiness, int procedureTime)
        {
            if (robotType != "PetRobot" && robotType != "HouseholdRobot" && robotType != "WalkerRobot")
            {
                throw new ArgumentException(string.Format(ExceptionMessages.InvalidRobotType, robotType));
            }

            if (energy < 0 || energy > 100)
            {
                throw new ArgumentException(ExceptionMessages.InvalidEnergy);
            }

            if (happiness < 0 || happiness > 100)
            {
                throw new ArgumentException(ExceptionMessages.InvalidHappiness);
            }

            if (garage.Robots.Count == 10)
            {
                throw new InvalidOperationException(ExceptionMessages.NotEnoughCapacity);
            }

            if (garage.Robots.ContainsKey(name))
            {
                throw new ArgumentException(string.Format(ExceptionMessages.ExistingRobot, name));
            }

            IRobot robot = null;


            if (robotType == "PetRobot")
            {
                robot = new PetRobot(name, energy, happiness, procedureTime);
            }

            else if (robotType == "HouseholdRobot")
            {
                robot = new HouseholdRobot(name, energy, happiness, procedureTime);
            }

            else if (robotType == "WalkerRobot")
            {
                robot = new WalkerRobot(name, energy, happiness, procedureTime);
            }

            garage.Manufacture(robot);

            return($"{String.Format(OutputMessages.RobotManufactured, name)}");
        }
        public string Manufacture(string robotType, string name, int energy, int happiness, int procedureTime)
        {
            //IRobot robot = null;
            //if (robotType == nameof(HouseholdRobot))
            //{
            //    robot = new HouseholdRobot(name, energy, happiness, procedureTime);
            //}
            //else if (robotType == nameof(PetRobot))
            //{
            //    robot = new PetRobot(name, energy, happiness, procedureTime); ;
            //}
            //else if (robotType == nameof(WalkerRobot))
            //{
            //    robot = new WalkerRobot(name, energy, happiness, procedureTime);
            //}
            //if (robot == null)
            //{
            //    throw new ArgumentException(string.Format(ExceptionMessages.InvalidRobotType, robotType));
            //}
            if (!Enum.TryParse(robotType, out RobotType currRobotType))
            {
                string msg = string.Format(ExceptionMessages.InvalidRobotType, robotType);
                throw new ArgumentException(msg);
            }

            IRobot robot = null;

            switch (currRobotType)
            {
            case RobotType.PetRobot:
                robot = new PetRobot(name, energy, happiness, procedureTime);
                break;

            case RobotType.HouseholdRobot:
                robot = new HouseholdRobot(name, energy, happiness, procedureTime);
                break;

            case RobotType.WalkerRobot:
                robot = new WalkerRobot(name, energy, happiness, procedureTime);
                break;
            }
            this.garage.Manufacture(robot);

            return(string.Format(OutputMessages.RobotManufactured, name));
        }
Example #14
0
        public string Manufacture(string robotType, string name, int energy, int happiness, int procedureTime) //dont check if exists
        {
            //ALTERNATIVE AND MORE ADVANCED METHOD, NOT MINE (including RobotTypeEnums in Utilites folder)
            //if (!Enum.TryParse(robotType, out RobotTypeEnums robotTypeEnum))
            //{
            //    throw new ArgumentException(string.Format(ExceptionMessages.InvalidRobotType, robotType));
            //}

            //IRobot robot = robotTypeEnum switch
            //{
            //    RobotTypeEnums.HouseholdRobot => new HouseholdRobot(name, energy, happiness, procedureTime),
            //    RobotTypeEnums.PetRobot => new PetRobot(name, energy, happiness, procedureTime),
            //    RobotTypeEnums.WalkerRobot => new WalkerRobot(name, energy, happiness, procedureTime),
            //    _ => null
            //};

            //my method:
            string[] types = new string[] { "HouseholdRobot", "PetRobot", "WalkerRobot" };
            if (!types.Contains(robotType))
            {
                throw new ArgumentException(string.Format(ExceptionMessages.InvalidRobotType, robotType));
            }

            IRobot robot = null;

            switch (robotType)
            {
            case "HouseholdRobot":
                robot = new HouseholdRobot(name, energy, happiness, procedureTime);
                break;

            case "PetRobot":
                robot = new PetRobot(name, energy, happiness, procedureTime);
                break;

            case "WalkerRobot":
                robot = new WalkerRobot(name, energy, happiness, procedureTime);
                break;
            }

            this.garage.Manufacture(robot);
            return($"Robot {name} registered successfully");
        }
        private static IRobot CreateRobot(string name, int energy, int happiness, int procedureTime, RobotTypes currRobotType)
        {
            IRobot robot = null;

            switch (currRobotType)
            {
            case RobotTypes.HouseholdRobot:
                robot = new HouseholdRobot(name, energy, happiness, procedureTime);
                break;

            case RobotTypes.WalkerRobot:
                robot = new WalkerRobot(name, energy, happiness, procedureTime);
                break;

            case RobotTypes.PetRobot:
                robot = new PetRobot(name, energy, happiness, procedureTime);
                break;
            }

            return(robot);
        }
Example #16
0
        public string Manufacture(string robotType, string name, int energy, int happiness, int procedureTime)
        {
            string result = "";

            if (!robotsTypes.Contains(robotType))
            {
                result = String.Format(ExceptionMessages.InvalidRobotType, robotType);
            }
            else
            {
                try
                {
                    IRobot robot = null;
                    switch (robotType)
                    {
                    case "HouseholdRobot":
                        robot = new HouseholdRobot(name, energy, happiness, procedureTime);
                        break;

                    case "PetRobot":
                        robot = new PetRobot(name, energy, happiness, procedureTime);
                        break;

                    case "WalkerRobot":
                        robot = new WalkerRobot(name, energy, happiness, procedureTime);
                        break;
                    }

                    this.garage.Manufacture(robot);
                    result = String.Format(OutputMessages.RobotManufactured, name);
                }
                catch (Exception message)
                {
                    result = message.Message;
                }
            }

            return(result);
        }
Example #17
0
        public IRobot CreateRobot(string robotType, string name, int energy, int happiness, int procedureTime)
        {
            IRobot robot = null;

            if (robotType == "HouseholdRobot")
            {
                robot = new HouseholdRobot(name, energy, happiness, procedureTime);
            }
            else if (robotType == "PetRobot")
            {
                robot = new PetRobot(name, energy, happiness, procedureTime);
            }
            else if (robotType == "WalkerRobot")
            {
                robot = new WalkerRobot(name, energy, happiness, procedureTime);
            }
            else
            {
                throw new ArgumentException(string.Format(ExceptionMessages.InvalidRobotType, robotType));
            }

            return(robot);
        }
Example #18
0
        private IRobot ProduceRobot(string robotType, string name, int energy, int happiness, int procedureTime)
        {
            IRobot robot = null;

            switch (robotType)
            {
            case "HouseholdRobot":
                robot = new HouseholdRobot(name, energy, happiness, procedureTime);
                break;

            case "PetRobot":
                robot = new PetRobot(name, energy, happiness, procedureTime);
                break;

            case "WalkerRobot":
                robot = new WalkerRobot(name, energy, happiness, procedureTime);
                break;

            default:
                throw new ArgumentException(String.Format(ExceptionMessages.InvalidRobotType, robotType));
            }
            return(robot);
        }
        public string Manufacture(string robotType, string name, int energy, int happiness, int procedureTime)
        {
            //Assembly assembly = Assembly.GetExecutingAssembly();
            //Type type = assembly.GetTypes().FirstOrDefault(x => x.Name == robotType);

            //if (type is null)
            //{
            //    throw new ArgumentException(string.Format(ExceptionMessages.InvalidRobotType, robotType));

            //}
            //object[] obj = new object[] { name, energy, happiness, procedureTime };
            //IRobot robot = (IRobot)Activator.CreateInstance(type, obj);

            IRobot robot;

            if (robotType == "HouseholdRobot")
            {
                robot = new HouseholdRobot(name, energy, happiness, procedureTime);
            }
            else if (robotType == "PetRobot")
            {
                robot = new PetRobot(name, energy, happiness, procedureTime);
            }
            else if (robotType == "WalkerRobot")
            {
                robot = new WalkerRobot(name, energy, happiness, procedureTime);
            }
            else
            {
                throw new ArgumentException(string.Format(ExceptionMessages.InvalidRobotType, robotType));
            }

            garage.Manufacture(robot);


            return($"Robot {name} registered successfully");
        }
 public PetTestsInorganic()
 {
     testPet = new PetRobot("CEPTAR", Constants.SPECIES_TYPE.DOG);
 }