Advertisement
GameNCode

Cube Tower Constructor

Sep 4th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. /**
  2. * Created by roywe on 9/3/2017.
  3. */
  4. public class CubeTower {
  5.  
  6. int maxCubes;
  7. int Cubes;
  8. Cube[] stackedcubes;
  9.  
  10. public CubeTower(int maxCubes, int Cubes, Cube[] stackedCubes)
  11. {
  12. this.maxCubes = maxCubes;
  13. this.Cubes = Cubes;
  14. this.stackedcubes = stackedCubes;
  15.  
  16. }
  17.  
  18. public int getMaxCubes() {
  19. return maxCubes;
  20. }
  21.  
  22. public void setMaxCubes(int maxCubes) {
  23. this.maxCubes = maxCubes;
  24. }
  25.  
  26. public int getCubes() {
  27. return Cubes;
  28. }
  29.  
  30. public void setCubes(int cubes) {
  31. Cubes = cubes;
  32. }
  33.  
  34. public Cube[] getStackedcubes() {
  35. return stackedcubes;
  36. }
  37.  
  38. public void setStackedcubes(Cube[] stackedcubes) {
  39. this.stackedcubes = stackedcubes;
  40. }
  41.  
  42. public void addCube()
  43. {
  44. if(maxCubes > Cubes)
  45. {
  46. Cubes++;
  47. stackedcubes[Cubes - 1] = new Cube();
  48. System.out.println("Cube added");
  49. }
  50. else
  51. {
  52. System.out.println("Failed to add cube");
  53. }
  54. }
  55.  
  56. public void minusCube()
  57. {
  58. if(0 < Cubes)
  59. {
  60. Cubes--;
  61. System.out.println("Removed cube");
  62. }
  63. else
  64. {
  65. System.out.println("Failed to remove cube");
  66. }
  67. }
  68. public void ColorFind(String color) {
  69. boolean flag = false;
  70. int counter = 0;
  71. while (!(flag)) {
  72. {
  73.  
  74. if (stackedcubes[counter].getColor().equals(color)) {
  75. System.out.println("The color " + color + " has been found");
  76. flag = true;
  77. } else if (counter == Cubes) {
  78. flag = true;
  79. System.out.println("The color " + color + " has not been found");
  80. }
  81. }
  82. }
  83. }
  84.  
  85. public void emptyCheck()
  86. {
  87. if(Cubes == 0)
  88. {
  89. System.out.println("The tower is empty");
  90. }
  91. else
  92. {
  93. System.out.println("The tower is not empty");
  94. }
  95. }
  96.  
  97. public void maxTower()
  98. {
  99. if(Cubes == maxCubes)
  100. {
  101. System.out.println("The tower is max");
  102. }
  103. else
  104. {
  105. System.out.println("The tower is not max");
  106. }
  107. }
  108. public void Equals()
  109. {
  110. boolean flag = false;
  111. Cube one = new Cube();
  112. Cube two = new Cube();
  113. while(!(flag)) {
  114. for (int i = 0; i < Cubes; i++) {
  115. one = stackedcubes[i];
  116. for (int k = 0; k < Cubes; k++) {
  117. two = stackedcubes[k];
  118. if (one.getZela() == two.getZela() && one.getColor() == two.getColor())
  119. {
  120. System.out.println("There are 2 equal cubes");
  121. }
  122. }
  123. }
  124. }
  125. }
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement