stack 소스
package ex;
class Stack1{
int[] stack = new int[10];
int point=0;
public Stack1(){
}
public boolean iS_Empty(){
if(point==0)
return true;
else
return false;
}
public boolean iS_Full(){
if(point>9)
return true;
else
return false;
}
public String push(int i){
if(iS_Full()==false)
{stack[point++]=i;return i+"를 넣는데 성공했습니다.";}
else
return "더이상 push를 할 수 없습니다.";
}
public String pop(){
if(iS_Empty()==false)
return stack[--point]+"를 꺼내는데 성공했습니다.";
else
return "더이상 pop()을 할수 없습니다";
}
}
public class CountTest{
public static void main(String[] args){
Stack1 st = new Stack1();
System.out.println(st.push(0));
System.out.println(st.push(1));
System.out.println(st.push(2));
System.out.println(st.push(3));
System.out.println(st.push(4));
System.out.println(st.push(5));
System.out.println(st.push(6));
System.out.println(st.push(7));
System.out.println(st.push(8));
System.out.println(st.push(9));
System.out.println(st.push(10));
System.out.println(st.pop());
}
}