Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by roywe on 9/3/2017.
- */
- public class CubeTower {
- int maxCubes;
- int Cubes;
- Cube[] stackedcubes;
- public CubeTower(int maxCubes, int Cubes, Cube[] stackedCubes)
- {
- this.maxCubes = maxCubes;
- this.Cubes = Cubes;
- this.stackedcubes = stackedCubes;
- }
- public int getMaxCubes() {
- return maxCubes;
- }
- public void setMaxCubes(int maxCubes) {
- this.maxCubes = maxCubes;
- }
- public int getCubes() {
- return Cubes;
- }
- public void setCubes(int cubes) {
- Cubes = cubes;
- }
- public Cube[] getStackedcubes() {
- return stackedcubes;
- }
- public void setStackedcubes(Cube[] stackedcubes) {
- this.stackedcubes = stackedcubes;
- }
- public void addCube()
- {
- if(maxCubes > Cubes)
- {
- Cubes++;
- stackedcubes[Cubes - 1] = new Cube();
- System.out.println("Cube added");
- }
- else
- {
- System.out.println("Failed to add cube");
- }
- }
- public void minusCube()
- {
- if(0 < Cubes)
- {
- Cubes--;
- System.out.println("Removed cube");
- }
- else
- {
- System.out.println("Failed to remove cube");
- }
- }
- public void ColorFind(String color) {
- boolean flag = false;
- int counter = 0;
- while (!(flag)) {
- {
- if (stackedcubes[counter].getColor().equals(color)) {
- System.out.println("The color " + color + " has been found");
- flag = true;
- } else if (counter == Cubes) {
- flag = true;
- System.out.println("The color " + color + " has not been found");
- }
- }
- }
- }
- public void emptyCheck()
- {
- if(Cubes == 0)
- {
- System.out.println("The tower is empty");
- }
- else
- {
- System.out.println("The tower is not empty");
- }
- }
- public void maxTower()
- {
- if(Cubes == maxCubes)
- {
- System.out.println("The tower is max");
- }
- else
- {
- System.out.println("The tower is not max");
- }
- }
- public void Equals()
- {
- boolean flag = false;
- Cube one = new Cube();
- Cube two = new Cube();
- while(!(flag)) {
- for (int i = 0; i < Cubes; i++) {
- one = stackedcubes[i];
- for (int k = 0; k < Cubes; k++) {
- two = stackedcubes[k];
- if (one.getZela() == two.getZela() && one.getColor() == two.getColor())
- {
- System.out.println("There are 2 equal cubes");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement