-
Notifications
You must be signed in to change notification settings - Fork 0
/
RoutingPointProblemStruct.cs
40 lines (37 loc) · 1.3 KB
/
RoutingPointProblemStruct.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace RoutingPointProblem
{
[TestClass]
public class RoutingCoordinates
{
[TestMethod]
public void TestRoutingCoordinates()
{
string[] newCommands = new string[] { "up", "right" };
NewFindLastPoint(startingPoint, newCommands);
Assert.AreEqual(startingPoint(1, 1), startingPoint(0, 0));
}
public struct point
{
public int x;
public int y;
public point (int startingX, int startingY)
{
x = startingX;
y = startingY;
}
}
public point startingPoint = new point(0,0);
public object NewFindLastPoint(point startingPoint,string[] newCommands)
{
for (int index = 0; index < newCommands.Length; index++)
{
if (newCommands[index] == "up") { y = startingY + 1; startingY = y; }
else if (newCommands[index] == "down") { y = startingY - 1; startingY = y; }
else if (newCommands[index] == "right") { x = startingX + 1; startingX = x; }
else if (newCommands[index] == "left") { x = startingX + 1; startingX = x; }
}
}
}
}