스택인데요.. 오류좀 잡아주세요
LetMeGo
공부하다가 함 짜밧는데요.. 어디가 잘못됐는지원...
부탁합니다...
import java.io.*;
import java.math.*;class stack
{
private string[] lifo;
private int stackcapacity;
private int stacktopindex;
private int entries;
public stack(int sizeofstack)
{
lifo = new string[sizeofstack];
stackcapacity = sizeofstack;
stacktopindex = -1;
entries = 0;
}
public void push(string item)
{
if(stacktopindex = stackcapacity)
{ system.out.println(더이상 들어갈수 없음);
stacktopindex++;
lifo[stacktopindex] = item;
}
}
public string pop()
{
if( stacktopindex == -1)
{
return 가득차있다;
}
return lifo[stacktopindex];
}
public string peek()
{
return lifo[stacktopindex--];
}
public int capacity()
{
return stackcapacity;
}
public int numberofitems()
{
return stacktopindex+1;
}
public boolean isempty()
{
if(entries == 0)
{
return true;
}
else
{
return false;
}
}
}
class stacktest
{
public static void main(string[] args)
{
stack one = new stack(10);
one.push(수업이다);
one.push(있는);
one.push(흥미);
one.push(너무);
one.push(하는데);
one.push(한번);
one.push(일주일에);
one.push(수업을);
one.push(자바);
one.push(우리는);
system.out.println(one.pop());
system.out.println(one.pop());
system.out.println(one.pop());
system.out.println(one.pop());
system.out.println(one.pop());
system.out.println(one.pop());
system.out.println(one.pop());
system.out.println(one.pop());
system.out.println(one.pop());
system.out.println(one.pop());
}
};