-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurrentstate.java
63 lines (53 loc) · 902 Bytes
/
currentstate.java
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class currentstate
{
int state;
String symbol;
int position;
public currentstate(int s, String sym, int pos)
{
state=s;
symbol=sym;
position=pos;
}
public int getstate()
{
return state;
}
public char getsymbol()
{
return symbol.charAt(position);
}
public void moveLorR(char lor)
{
if (lor=='L')
{
position--;
}
else {
position++;
}
if(symbol.length() < position+1)
{
symbol=symbol+'B';
}
if(position<0)
{
position=0;
symbol = 'B' + symbol;
}
}
public void setstate(int s)
{
state = s;
}
public void setsym(char a)
{
String s1="";
s1 = symbol.substring(0,position) + a + symbol.substring(position+1);
symbol = s1;
}
public void print()
{
System.out.println(symbol + " state :" +state + " position :" +position);
}
}