-1
스택에 대한 Java 코드가 있습니다. 아래의 방법을 채우려면 도움이 필요합니다 : create method
또는 create constructor here
.Java 배열 스택 구현
public class ArrayStack
{
private int[] A;
private int top;
public ArrayStack()
{
create constructor here
}
public ArrayStack(int maxsize)
{
create constructor here
}
public boolean isEmpty() {
create method
}
public boolean isFull()
{
create method
}
public int peek()
{
if(isEmpty())
throw new RuntimeException("Peek attempted on empty stack");
else
return A[top];
}
public void push(int m)
{
if(isFull())
throw new RuntimeException("Push attempted on full stack");
else
{
top++;
A[top]=m;
}
}
public int pop()
{
if(isEmpty())
throw new RuntimeException("Pop attempted on empty stack");
else
{
int value = A[top];
top--;
return value;
}
}
public int size()
{
return (top + 1);
}
public String toString()
{
String answer = "";
int i;
for(i = 0; i <= top; i++)
answer = "\n" + A[i] + answer;
return answer;
}
}
이 질문은 코드 작성 요청이기 때문에 주제가 아닌 것처럼 보입니다. –
@ Jason 우리는 숙제를 돕지 만 다른 질문과 같은 기준으로 돕습니다. – chrylis
['ArrayDeque']를 사용하지 않는 이유는 무엇입니까? (http://docs.oracle.com/javase/7/docs/api/java/util/ArrayDeque.html)? –