Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Extract out tape class in BrainmessShort
- Loading branch information
1 parent
746f4e3
commit c75cc6a
Showing
3 changed files
with
55 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
|
||
namespace BrainmessShort | ||
{ | ||
public class Tape | ||
{ | ||
private readonly int[] tape = new int[5000]; | ||
private int tc = 2500; | ||
|
||
public int MoveForward() | ||
{ | ||
return tc++; | ||
} | ||
|
||
public int MoveBackward() | ||
{ | ||
return tc--; | ||
} | ||
|
||
public int Increment() | ||
{ | ||
return tape[tc]++; | ||
} | ||
|
||
public int Decrement() | ||
{ | ||
return tape[tc]--; | ||
} | ||
|
||
public int Current | ||
{ | ||
get | ||
{ | ||
return tape[tc]; | ||
} | ||
set | ||
{ | ||
tape[tc] = value; | ||
} | ||
} | ||
} | ||
} | ||
|