|
|
@@ -23,6 +23,7 @@ public class Stack {
|
|
|
this.capacity = capacity;
|
|
|
this.elementType = elementType;
|
|
|
this.content = content;
|
|
|
+ this.size=content.size();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -33,6 +34,8 @@ public class Stack {
|
|
|
public Stack( String elementType, ArrayList<Object> content) {
|
|
|
this.elementType = elementType;
|
|
|
this.content = content;
|
|
|
+ this.capacity=MAX_SIZE;
|
|
|
+ this.size=content.size();
|
|
|
}
|
|
|
|
|
|
public Stack() {
|
|
|
@@ -105,4 +108,17 @@ public class Stack {
|
|
|
public void setContent(ArrayList<Object> content) {
|
|
|
this.content = content;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ //toString
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String toString() {
|
|
|
+ return "Stack{" +
|
|
|
+ "capacity=" + capacity +
|
|
|
+ ", size=" + size +
|
|
|
+ ", elementType='" + elementType + '\'' +
|
|
|
+ ", content=" + content +
|
|
|
+ '}';
|
|
|
+ }
|
|
|
}
|