Please check your converted code to java
Code:
class Stack
{
public static int MaxStack = 10;
public static int MaxMaze = 5;
int item [MaxStack];
int my top;
public Stack()
{
mytop =- 1;
}
public int IsEmpty()
{
return (mytop == -1);
}
public void push(int val)
{
if (mytop == MaxStack - 1)
{
System.out.println("Stack Is Full");
return ;
}
item[++mytop] = val;
}
public pop()
{
if(IsEmpty())
{
System.out.println("Stack Is Empty");
}
return -1;
}
return item[mytop--];
}
public static void main (String args[])
{
char a[MaxMaze][MaxMaze] = {
{' ',' ','*','*','*'},
{'*',' ','*',' ',' '},
{'*',' ','*',' ','*'},
{'*',' ',' ',' ','*'},
{'*','*','*','*','*'}
};
Stack s1 = new Stack();
Stack s1 = new Stack();
int i = 0 , j = 0;
while(j>=0 && i>=0)
{
while(i>=0 && a[i][j]!='*' && a[i][j]!='-')
{
while(j<MaxMaze && a[i][j] !='*' && a[i][j]!='-')
{
while(i<MaxMaze && a[i][j] !='*' && a[i][j]!='-')
{
a[i][j]='-';
s1.push(i);
i++;
}
i=s1.pop();
s2.push(j);
j++;
}
j=s2.pop();
s1.push(i);
i--;
}
i=s1.pop();
s2.push(j);
j--;
}
for(i=0;i<MaxMaze;i++)
{
for(j=0;j<MaxMaze;j++)
System.out.println(a[i][j]);
System.out.println();
}
}
If any problem post back
Bookmarks