Skip to content

Commit

Permalink
Fixed a bug where the band could only end to the right
Browse files Browse the repository at this point in the history
  • Loading branch information
Abbin44 committed Aug 29, 2020
1 parent 6c9118f commit bb60b38
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
17 changes: 3 additions & 14 deletions Conveyer/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ 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");
Console.ReadKey();
return;
}
filePath = args[0];

height = File.ReadLines(filePath).Count();

FileHandler fh = new FileHandler(filePath);
Console.ReadKey();
}

static public void CreateArray(int length)
Expand Down Expand Up @@ -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();
}
Expand Down
3 changes: 3 additions & 0 deletions Conveyer/Conveyer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Conveyer.Controller</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
1 change: 1 addition & 0 deletions Conveyer/OutputQueue.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Text.RegularExpressions;

Expand Down
14 changes: 8 additions & 6 deletions Conveyer/Scanner.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Text.RegularExpressions;
using System;
using System.IO;
using System.Text.RegularExpressions;

namespace Conveyer
{
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit bb60b38

Please sign in to comment.