diff --git a/Conveyer/Controller.cs b/Conveyer/Controller.cs
index a8b3c09..5dabb40 100644
--- a/Conveyer/Controller.cs
+++ b/Conveyer/Controller.cs
@@ -13,6 +13,7 @@ class Controller
static void Main(string[] args)
{
// Check for correct file format and length
+
if (!(args.Length == 1 && args[0].EndsWith(".coy")))
{
Console.WriteLine("Code not a valid file");
@@ -20,9 +21,11 @@ static void Main(string[] args)
return;
}
filePath = args[0];
+
height = File.ReadLines(filePath).Count();
FileHandler fh = new FileHandler(filePath);
+ Console.ReadKey();
}
static public void CreateArray(int length)
@@ -53,20 +56,6 @@ static public void CreateArray(int length)
//Close streamreader to avoid memory leak
sr.Close();
- #region PrintArray
- /*
- //Print array
- for (int i = 0; i < map.GetLength(0); i++)
- {
- for (int j = 0; j < map.GetLength(1); j++)
- {
- Console.Write(string.Format("{0} ", map[i, j]));
- }
- Console.Write(Environment.NewLine + Environment.NewLine);
- }
- */
- #endregion
-
Scanner sc = new Scanner(length, map, filePath);
Console.ReadKey();
}
diff --git a/Conveyer/Conveyer.csproj b/Conveyer/Conveyer.csproj
index f81a3ce..c1d0cd6 100644
--- a/Conveyer/Conveyer.csproj
+++ b/Conveyer/Conveyer.csproj
@@ -32,6 +32,9 @@
prompt
4
+
+ Conveyer.Controller
+
diff --git a/Conveyer/OutputQueue.cs b/Conveyer/OutputQueue.cs
index 21bb757..7d7c0ff 100644
--- a/Conveyer/OutputQueue.cs
+++ b/Conveyer/OutputQueue.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using System.Collections.Generic;
using System.Text.RegularExpressions;
diff --git a/Conveyer/Scanner.cs b/Conveyer/Scanner.cs
index 86992b0..518d370 100644
--- a/Conveyer/Scanner.cs
+++ b/Conveyer/Scanner.cs
@@ -1,4 +1,6 @@
-using System.Text.RegularExpressions;
+using System;
+using System.IO;
+using System.Text.RegularExpressions;
namespace Conveyer
{
@@ -43,12 +45,12 @@ void Scan(int length, char[,] _map)
goRight = false;
}
- if (_map[h - 1, l] == '^') //Check For Direction --> go up
+ if (_map[h, l] == '^') //Check For Direction --> go up
{
goUp = true;
moveSideways = false;
}
- if (_map[h - 1, l] == 'ᵥ') //Check For Direction --> go down
+ if (_map[h, l] == 'ᵥ') //Check For Direction --> go down
{
goUp = false;
moveSideways = false;
@@ -65,17 +67,17 @@ void Scan(int length, char[,] _map)
h--;
}
- if (_map[h + 1, l - 2] == '‾' && goRight == false && moveSideways == true) //Go left
+ if (_map[h - 1, l - 2] == '_' && goRight == false && moveSideways == true) //Go left
{
l--;
}
- if (_map[h + 1, l + 2] == '‾' && goRight == true && moveSideways == true) //Go right
+ if (_map[h - 1, l + 2] == '_' && goRight == true && moveSideways == true) //Go right
{
l++;
}
- if (_map[h, l + 1] == '~') //End of conveyor belt
+ if (_map[h, l + 1] == '~' || _map[h, l - 1] == '~' || _map[h + 1, l] == '~' || _map[h - 1, l] == '~') //End of conveyor belt
{
//Console.WriteLine("Mission Complete!");
OutputQueue.PrintResult(); //Print all the letters on the conveoyr belt