Stack.java 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package com.example.data_structure.domain;
  2. import java.util.ArrayList;
  3. public class Stack {
  4. public static final int MAX_SIZE =20;
  5. private int capacity; //栈的最大容量
  6. private int size; //栈现有的元素数
  7. private String elementType; //栈元素的类型,有char,String,int,double四种类型
  8. private ArrayList<Object> content;
  9. /**
  10. * 指定最大容量的构造方法
  11. * @param capacity
  12. * @param elementType
  13. * @param content
  14. */
  15. public Stack(int capacity,String elementType, ArrayList<Object> content) {
  16. this.capacity = capacity;
  17. this.elementType = elementType;
  18. this.content = content;
  19. }
  20. /**
  21. * 不指定最大容量的构造方法
  22. * @param elementType
  23. * @param content
  24. */
  25. public Stack( String elementType, ArrayList<Object> content) {
  26. this.elementType = elementType;
  27. this.content = content;
  28. }
  29. private boolean isFull(){
  30. return false;
  31. }
  32. private boolean isEmpty(){
  33. return true;
  34. }
  35. /**
  36. * push操作成功返回true,否则返回false
  37. * @return
  38. */
  39. public boolean push(){
  40. return false;
  41. }
  42. /**
  43. * pop()操作成功返回true,否则返回false
  44. * @return
  45. */
  46. public boolean pop(){
  47. return false;
  48. }
  49. public void makeEmpty(){
  50. }
  51. }