/// <summary> /// Move Efront /// </summary> /// <param name="front">Efront</param> /// <param name="move">move</param> /// <returns>efront moved</returns> public static EFront Move(this EFront front, char move) { var position = (int)front; switch (move) { case 'L': position += 1; if (position > 3) { position -= 4; } break; case 'R': position -= 1; if (position < 0) { position += 4; } break; default: break; } return((EFront)position); }
public void Move_R(EFront front, EFront response) { // Act var result = front.Move('R'); // Assert Assert.Equal(response, result); }
public void Move_R(EFront front, string result) { // Arrange var sonda = new Sonda(front: front); // Act sonda.Move('R'); // Assert Assert.Equal(result, sonda.ToString()); }
/// <summary> /// Move /// </summary> /// <param name="move">movement char</param> public void Move(char move) { if (move == 'M') { Position.Move(Front); } else { Front = Front.Move(move); } }
public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); var lChecker = new RepeatItemNameChecker(); mFront = (EFront)Enum.Parse(typeof(EFront), lReader.getAttribute <String>("Front")); mPositiveInc = lReader.getAttribute <Boolean>("PositiveIncrease"); mNegativeInc = lReader.getAttribute <Boolean>("NegativeIncrease"); string lItem = lReader.getAttribute <String>("Input"); lChecker.addItemName(lItem); mInValueItemHandle = mItemBrowser.getItemHandleByName(lItem); lItem = lReader.getAttribute <String>("Output"); lChecker.addItemName(lItem); mOutValueItemHandle = mItemBrowser.getItemHandleByName(lItem); }
/// <summary> /// Move based on front /// </summary> /// <param name="front">front</param> public void Move(EFront front) { switch (front) { case EFront.N: X++; break; case EFront.W: Y--; break; case EFront.S: X--; break; case EFront.E: Y++; break; default: break; } }
/// <summary> /// Constructor /// </summary> /// <param name="x">X</param> /// <param name="y">Y</param> /// <param name="front">Front</param> public Sonda(int x = 0, int y = 0, EFront front = EFront.N) { Position = new Position(x, y); Front = front; }