public void CannotCreateWithInvalidValues() { console.WriteLine("0"); Assert.Throws <ArgumentOutOfRangeException> (() => RobotFactory.CreateRobot(console)); console.WriteLine("10001"); Assert.Throws <ArgumentOutOfRangeException> (() => RobotFactory.CreateRobot(console)); }
public Controller() { this.robotFactory = new RobotFactory(); this.garage = new Garage(); this.procedures = new Dictionary <string, IProcedure>(); this.InitializeProcedures(); }
void StartRobot(string robotname) { btnDFFB.Enabled = false; btnJJC.Enabled = false; btnMY.Enabled = false; new Thread(() => { Robot rbt = RobotFactory.GetRobot(robotname); currRot = rbt; websocket.MessageReceived += new EventHandler <MessageReceivedEventArgs>(rbt.websocket_MessageReceived); rbt.SendMessageEvent += Robot_SendMessageEvent; rbt.SendQuickMessageEvent += Robot_SendQuickMessageEvent; rbt.SendWaitMessageEvent += Robot_SendWaitMessageEvent; rbt.IsContinue = true; while (rbt.IsContinue) { rbt.Run(); } rbt.Run(); websocket.MessageReceived -= new EventHandler <MessageReceivedEventArgs>(rbt.websocket_MessageReceived); this.Invoke(new Action(() => { btnDFFB.Enabled = true; btnJJC.Enabled = true; btnMY.Enabled = true; })); }).Start(); }
private void Awake() { levelGenerator = GetComponent <LevelGenerator>(); levelGeometry = levelGenerator.Generate(); levelGeometry.parent = transform; levelGeometry.position -= Vector3.forward * levelGenerator.LaneSize; initialPosition = levelGeometry.position; var robot = RobotFactory.GetRobot(RobotChangeManager.CurrentType); robotMov = robot.GetComponent <RobotMovement> (); Debug.Assert(robotMov != null, "Robot Prefab has no Robot Movement Component"); robotMov.Init(this); var spawners = GetComponentsInChildren <Spawner> (); foreach (var s in spawners) { s.Init(this); } var hudController = GetComponentInChildren <HUDController> (); if (hudController != null) { hudController.Init(robot); } FillAvailableLastLanes(); }
public void TestCorrectSpinningOfRobot() { Arena.Instance.Init(5, 5);; int robotId = RobotFactory.CreateRobot(2, 2, RobotOrientation.N); Arena.Instance.Move(robotId, RobotCommandType.L); Assert.AreEqual(Arena.Instance.GetRobot(robotId).Orientation, RobotOrientation.W); Arena.Instance.Move(robotId, RobotCommandType.L); Assert.AreEqual(Arena.Instance.GetRobot(robotId).Orientation, RobotOrientation.S); Arena.Instance.Move(robotId, RobotCommandType.L); Assert.AreEqual(Arena.Instance.GetRobot(robotId).Orientation, RobotOrientation.E); Arena.Instance.Move(robotId, RobotCommandType.L); Assert.AreEqual(Arena.Instance.GetRobot(robotId).Orientation, RobotOrientation.N); Arena.Instance.Move(robotId, RobotCommandType.R); Assert.AreEqual(Arena.Instance.GetRobot(robotId).Orientation, RobotOrientation.E); Arena.Instance.Move(robotId, RobotCommandType.R); Assert.AreEqual(Arena.Instance.GetRobot(robotId).Orientation, RobotOrientation.S); Arena.Instance.Move(robotId, RobotCommandType.R); Assert.AreEqual(Arena.Instance.GetRobot(robotId).Orientation, RobotOrientation.W); Arena.Instance.Move(robotId, RobotCommandType.R); Assert.AreEqual(Arena.Instance.GetRobot(robotId).Orientation, RobotOrientation.N); }
public static void Main(string[] args) { string response; var jsonParameters = LoadRobotParameters(args[0]); var robotCreationResult = RobotFactory.GetRobot(jsonParameters); if (robotCreationResult.Item1.Equals(RobotConstructionStatus.Error)) { response = "Parameters are not valid"; } else { try { response = JsonConvert.SerializeObject(robotCreationResult.Item2.Clean()); } catch (RobotCleanerException e) { Console.WriteLine(e.Message); response = e.Response; } } WriteResponse(response); }
public void test05_Checks_That_Adds_Robor_In_The_List() { #region Arrange pieces = new List <RobotPiece>(); aRobot = new Robot(EOrigin.Earth, EModelName.WallE, pieces); #endregion #region Act int listSizeBefore = RobotFactory.Robots.Count; bool addToWarehouse = RobotFactory.AddRobotToWarehouse(aRobot); int listSizeAfter = RobotFactory.Robots.Count; #endregion #region Assert Assert.AreEqual(0, listSizeBefore); Assert.IsTrue(addToWarehouse); Assert.AreEqual(1, listSizeAfter); #endregion }
private static void StartTheRobot() { var minCoordinate = Coordinate.CreateInstance(-100_000, -100_000); var maxCoordinate = Coordinate.CreateInstance(100_000, 100_000); var commandsCount = PrintOutInput("Please enter the number of robot commands:"); var startingPosition = PrintOutInput("Please enter the starting position coordinates {x y}:"); var commands = new List <string>(); for (var i = 1; i <= int.Parse(commandsCount); i++) { var cmd = PrintOutInput($"Please enter the command number ({i}):"); commands.Add(cmd); } var inputs = new InputsModel { StartingPosition = startingPosition, Commands = commands }; _robot = RobotFactory.CreateRobot(inputs, minCoordinate, maxCoordinate); _robot.StartCleaning(); }
public Engine(IReader reader, IWriter writer) { this.reader = reader; this.writer = writer; citizenFactory = new CitizenFactory(); robotFactory = new RobotFactory(); list = new List <string>(); }
public void TestNotCorrectCreationOutOfBounderies() { Arena.Instance.Init(10, 10); Assert.ThrowsException <Exception>(() => RobotFactory.CreateRobot(2, 14, RobotOrientation.E), "Robot Y position cannot be greater than 10"); Assert.ThrowsException <Exception>(() => RobotFactory.CreateRobot(10, 1, RobotOrientation.E), "Robot X position cannot be greater than 10"); Assert.ThrowsException <Exception>(() => RobotFactory.CreateRobot(-1, 1, RobotOrientation.E), "Robot X position cannot be lower than 0"); Assert.ThrowsException <Exception>(() => RobotFactory.CreateRobot(5, -2, RobotOrientation.E), "Robot Y position cannot be lower than 0"); }
public void TestOutOfTopRightBounderiesException() { Arena.Instance.Init(5, 5);; int robotId = RobotFactory.CreateRobot(4, 4, RobotOrientation.E); Assert.ThrowsException <Exception>(() => Arena.Instance.Move(robotId, RobotCommandType.M), "Robot cannot move to East, it is already at the limit"); Arena.Instance.Move(robotId, RobotCommandType.L); Assert.ThrowsException <Exception>(() => Arena.Instance.Move(robotId, RobotCommandType.M), "Robot cannot move to North, it is already at the limit"); }
public void StartLevel(PlayerManager playerManager, RobotFactory factory) { this.playerManager = playerManager; levelActive = true; SpawnRobots(factory); playerManager.StartLevel(); Debug.Log("Started level " + ToString()); }
public void TestOutOfLeftBottomBounderiesException() { Arena.Instance.Init(5, 5);; int robotId = RobotFactory.CreateRobot(0, 0, RobotOrientation.W); Assert.ThrowsException <Exception>(() => Arena.Instance.Move(robotId, RobotCommandType.M), "Robot cannot move to West, it is already at the limit"); Arena.Instance.Move(robotId, RobotCommandType.L); Assert.ThrowsException <Exception>(() => Arena.Instance.Move(robotId, RobotCommandType.M), "Robot cannot move to South, it is already at the limit"); }
public void GivenValidInstructions() { var instructions = new List<Instruction>() { new ForwardInstruction(), new LeftInstruction(), new RightInstruction() }; this.robotFactory = new RobotFactory(instructions); }
public void TestCorrectCreation() { Arena.Instance.Init(10, 10); int robotId = RobotFactory.CreateRobot(2, 4, RobotOrientation.E); Assert.AreNotEqual(robotId, 0); Assert.AreEqual(Arena.Instance.GetRobot(robotId).X, 2); Assert.AreEqual(Arena.Instance.GetRobot(robotId).Y, 4); Assert.AreEqual(Arena.Instance.GetRobot(robotId).Orientation, RobotOrientation.E); }
public void ShouldCreateRobotSuccessfully() { console.WriteLine("2"); console.WriteLine("10 22"); console.WriteLine("N 2"); console.WriteLine("E 1"); var robot = RobotFactory.CreateRobot(console); Assert.That(robot, Is.Not.Null); }
public IChallenge InitializeChallenge(ChallengeConfiguration configuration) { IChallenge challenge = ChallengeFactory.CreateChallenge(configuration.ChallengeGuid); if (challenge != null) { List <IRobot> robots = RobotFactory.CreateRobots(configuration.Robots); challenge.Initialize(robots, configuration.ChallengeMatDetails, configuration.IsSinglePlayer); } return(challenge); }
static void Main(string[] args) { DisplayIntroductoryText(); IRobot robot = RobotFactory.Create(TABLE_LENGTH, TABLE_WIDTH); while (true) { string command = Console.ReadLine(); robot.ExecuteCommand(command); } }
/// <summary> /// EventHandler of the button 'btnInitializeFactory'. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnInitializeFactory_Click(object sender, EventArgs e) { if (!isEnabled && RobotFactory.InitFactoryAndStock()) { isEnabled = !isEnabled; this.GetMaterialStock(); LockButtons(isEnabled); } else { MessageBox.Show("The factory has been already initialized"); } }
public void TestRobotFactories() { rf = new CyborgRobotFactory(); Assert.IsInstanceOfType(rf.Generate(""), typeof(CyborgRobot)); rf = new ScienceRobotFactory(); Assert.IsInstanceOfType(rf.Generate(""), typeof(ScienceRobot)); rf = new WorkerRobotFactory(); Assert.IsInstanceOfType(rf.Generate(""), typeof(WorkerRobot)); }
static void Main(string[] args) { var robotFactory = new RobotFactory(new JsonDataSource()); var robot = robotFactory.CreateRobot(); Console.WriteLine(robot); robotFactory.ResetId(robot); Console.WriteLine(robot); ConsoleTools.CloseProgram(); }
/// <summary> /// EventHandler of the formClosing. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmLobby_FormClosing(object sender, FormClosingEventArgs e) { if (MessageBox.Show("Are you sure to quit?", "Leaving", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { RobotFactory.SaveDataOfFactory(); formShut = new frmShutdown(); formShut.ShowDialog(); MyPlayer.Stop(); this.Dispose(); } else { e.Cancel = true; } }
static void Main(string[] args) { var consoleReader = new ConsoleInputReader() .ReadNumberOfCommands() .ReadStartPosition() .ReadCommands(); var robot = RobotFactory.CreateCleaningRobotAt(consoleReader.StartPosition); var textCommander = new TextCommander(robot); foreach (var command in consoleReader.Commands) { textCommander.Execute(command); } Console.WriteLine("=> Cleaned: " + robot.GetLog().CleanedStations); }
public void Test03_Check_Not_Enough_Material_To_Manufacture() { #region Arrange #endregion #region Act bool enoughMaterials = RobotFactory.CheckAmountOfMaterialsInBuckets((int)EModelName.DragonZord); #endregion #region Assert Assert.IsFalse(enoughMaterials); #endregion }
private void StartRobots() { if (bool.Parse(ConfigurationManager.AppSettings["EnableRobots"])) { WriteLog("Start Robots", EventLogEntryType.Information); var factory = RobotFactory.CreateFactory(); _robots = factory.CreateRobots(); foreach (var robot in _robots) { robot.Start(_fts); } WriteLog("Robots Started.", EventLogEntryType.Information); } }
public void OnBuildingSelection(string building) { Building b = this.Buildings.FirstOrDefault(keyValPair => keyValPair.Key == this.ActConsBlockPos).Value; Dictionary <byte, int> actualRessources = null; if (b != null) { if (b.Built) { return; } actualRessources = b.ActualRessources; } switch (building) { case "HQ": b = new HeadQuarter(this.mStateMgr, this.mIsland, this.mRTSManager.PlayerRTS); break; case "CD": b = new CrystalDrill(this.mStateMgr, this.mIsland, this.mRTSManager.PlayerRTS); break; case "RF": b = new RobotFactory(this.mStateMgr, this.mIsland, this.mRTSManager.PlayerRTS); break; case "G": b = new Generator(this.mStateMgr, this.mIsland, this.mRTSManager.PlayerRTS); break; } if (actualRessources == null) { actualRessources = b.NeededRessources.Keys.ToDictionary(key => key, key => 0); } b.ActualRessources = actualRessources; if (!this.Buildings.ContainsKey(this.ActConsBlockPos)) { this.Buildings.Add(this.ActConsBlockPos, b); } b.DrawRemainingRessource(); }
public void cheer() { Console.WriteLine("cheer"); Robot [] factory = new Robot[10]; RobotFactory factory2 = new RobotFactory(); Robot target2 = factory2[10]; if (target2 != null) { target2.hp = 100; } Robot target1 = factory[10]; if (target1 != null) { target1.hp = 100; } }
/// <summary> /// Load Event Handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmLobby_Load(object sender, EventArgs e) { frmOpening opening = new frmOpening(); opening.ShowDialog(); try { MyPlayer.Play("MainTheme", true); if (File.Exists(fullMpersistencePath)) { RobotFactory.Buckets = smb.Read(fullMpersistencePath); } if (File.Exists(fullRpersistencePath)) { RobotFactory.Robots = smr.Read(fullRpersistencePath); RobotFactory.ChargeBiography(biographyPath); } } catch (Exception ex) { frmLobby.FormExceptionHandler(ex); } }
public static void Demo() { ManFactory manFactory = new ManFactory(); WomanFactory womanFactory = new WomanFactory(); RobotFactory robotFactory = new RobotFactory(); List <Person> people = new List <Person> { manFactory.CreatePerson(), womanFactory.CreatePerson(), robotFactory.CreatePerson(), robotFactory.CreatePerson(), manFactory.CreatePerson(), }; foreach (Person item in people) { item.doSomethins(); } }
/// <summary> /// Creates multiples pieces of the robot. /// </summary> /// <param name="metalType">Type Of metal of the robot.</param> /// <param name="origin">Origin of the robot.</param> /// <param name="modelName">Model name of the robot.</param> /// <param name="amountHead">Amount of heads of the robot.</param> /// <param name="amounTorso">Amount of torsos of the robot.</param> /// <param name="amountArms">Amount of arms of the robot.</param> /// <param name="amountLegs">Amount of legs of the robot.</param> /// <param name="amountTail">Amount of tails of the robot.</param> /// <param name="isRidable">boolean state that indicates if the robot is rideable or not.</param> private void ConfigureRobotForBuild(EMetalType metalType, EOrigin origin, EModelName modelName, int amountHead, int amounTorso, int amountArms, int amountLegs, int amountTail, bool isRidable) { amountOfMaterials = (int)modelName; int amountPieces = amountHead + amountArms + amountLegs + amounTorso + amountTail; int totalMaterialsForEachPiece = amountOfMaterials * amountPieces; if (RobotFactory.CheckAmountOfMaterialsInBuckets(totalMaterialsForEachPiece)) { Robot prototype; prototype = RobotFactory.CreateMultiplePiecesAndAddToStock(metalType, origin, modelName, amountOfMaterials, amountHead, amounTorso, amountArms, amountLegs, amountTail, isRidable); filename = prototype.Model.ToString(); absBioPath = $"{pathBiography}{filename}.bin"; prototype.LoadBioFile(absBioPath); try { if (RobotFactory.QualityControl(prototype, amountPieces)) { if (RobotFactory.AddRobotToWarehouse(prototype)) { ShowFormBuildingWithSound(); RobotFactory.SaveDataOfFactory(); prototype.SetSerialNumber(); DataAccessManager.InsertRobot(prototype); ShowFormISOWithSound(prototype); } } else { if (RobotFactory.DissasembleRobot(prototype)) { throw new QualityControlFailedException("There have a difference in the amount of pieces, Quality control has failed!. For safety reasons, the robot was dismantled and its materials recycled."); } } } catch (Exception e) { throw new Exception(e.Message, e); } } else { throw new InsufficientMaterialsException("Insufficients Materials to build this model of robot, you need to import more materials in the machine room or choose another model."); } }
public void Test04_Robot_Fails_In_Quality() { #region Arrange pieces = new List <RobotPiece>(); aRobot = new Robot(EOrigin.Earth, EModelName.WallE, pieces); #endregion #region Act bool failQualityControl = RobotFactory.QualityControl(aRobot, (int)aRobot.Model); #endregion #region Assert Assert.IsFalse(failQualityControl); #endregion }
public void TestCorrectMovingOfRobot() { Arena.Instance.Init(5, 5);; int robotId = RobotFactory.CreateRobot(2, 2, RobotOrientation.N); Arena.Instance.Move(robotId, RobotCommandType.L); Arena.Instance.Move(robotId, RobotCommandType.M); Assert.AreEqual(Arena.Instance.GetRobot(robotId).X, 1); Arena.Instance.Move(robotId, RobotCommandType.L); Arena.Instance.Move(robotId, RobotCommandType.M); Assert.AreEqual(Arena.Instance.GetRobot(robotId).Y, 1); Arena.Instance.Move(robotId, RobotCommandType.L); Arena.Instance.Move(robotId, RobotCommandType.M); Assert.AreEqual(Arena.Instance.GetRobot(robotId).X, 2); Arena.Instance.Move(robotId, RobotCommandType.L); Arena.Instance.Move(robotId, RobotCommandType.M); Assert.AreEqual(Arena.Instance.GetRobot(robotId).Y, 2); }