Skip to content

Commit bb60b38

Browse files
committed
Fixed a bug where the band could only end to the right
1 parent 6c9118f commit bb60b38

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

Conveyer/Controller.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ class Controller
1313
static void Main(string[] args)
1414
{
1515
// Check for correct file format and length
16+
1617
if (!(args.Length == 1 && args[0].EndsWith(".coy")))
1718
{
1819
Console.WriteLine("Code not a valid file");
1920
Console.ReadKey();
2021
return;
2122
}
2223
filePath = args[0];
24+
2325
height = File.ReadLines(filePath).Count();
2426

2527
FileHandler fh = new FileHandler(filePath);
28+
Console.ReadKey();
2629
}
2730

2831
static public void CreateArray(int length)
@@ -53,20 +56,6 @@ static public void CreateArray(int length)
5356
//Close streamreader to avoid memory leak
5457
sr.Close();
5558

56-
#region PrintArray
57-
/*
58-
//Print array
59-
for (int i = 0; i < map.GetLength(0); i++)
60-
{
61-
for (int j = 0; j < map.GetLength(1); j++)
62-
{
63-
Console.Write(string.Format("{0} ", map[i, j]));
64-
}
65-
Console.Write(Environment.NewLine + Environment.NewLine);
66-
}
67-
*/
68-
#endregion
69-
7059
Scanner sc = new Scanner(length, map, filePath);
7160
Console.ReadKey();
7261
}

Conveyer/Conveyer.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
<ErrorReport>prompt</ErrorReport>
3333
<WarningLevel>4</WarningLevel>
3434
</PropertyGroup>
35+
<PropertyGroup>
36+
<StartupObject>Conveyer.Controller</StartupObject>
37+
</PropertyGroup>
3538
<ItemGroup>
3639
<Reference Include="System" />
3740
<Reference Include="System.Core" />

Conveyer/OutputQueue.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.IO;
23
using System.Collections.Generic;
34
using System.Text.RegularExpressions;
45

Conveyer/Scanner.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Text.RegularExpressions;
1+
using System;
2+
using System.IO;
3+
using System.Text.RegularExpressions;
24

35
namespace Conveyer
46
{
@@ -43,12 +45,12 @@ void Scan(int length, char[,] _map)
4345
goRight = false;
4446
}
4547

46-
if (_map[h - 1, l] == '^') //Check For Direction --> go up
48+
if (_map[h, l] == '^') //Check For Direction --> go up
4749
{
4850
goUp = true;
4951
moveSideways = false;
5052
}
51-
if (_map[h - 1, l] == 'ᵥ') //Check For Direction --> go down
53+
if (_map[h, l] == 'ᵥ') //Check For Direction --> go down
5254
{
5355
goUp = false;
5456
moveSideways = false;
@@ -65,17 +67,17 @@ void Scan(int length, char[,] _map)
6567
h--;
6668
}
6769

68-
if (_map[h + 1, l - 2] == '' && goRight == false && moveSideways == true) //Go left
70+
if (_map[h - 1, l - 2] == '_' && goRight == false && moveSideways == true) //Go left
6971
{
7072
l--;
7173
}
7274

73-
if (_map[h + 1, l + 2] == '' && goRight == true && moveSideways == true) //Go right
75+
if (_map[h - 1, l + 2] == '_' && goRight == true && moveSideways == true) //Go right
7476
{
7577
l++;
7678
}
7779

78-
if (_map[h, l + 1] == '~') //End of conveyor belt
80+
if (_map[h, l + 1] == '~' || _map[h, l - 1] == '~' || _map[h + 1, l] == '~' || _map[h - 1, l] == '~') //End of conveyor belt
7981
{
8082
//Console.WriteLine("Mission Complete!");
8183
OutputQueue.PrintResult(); //Print all the letters on the conveoyr belt

0 commit comments

Comments
 (0)