I want to get the ID of an actor, here is the class and constructor
(I'm making the Hanoi game btw, and i want to know the ID or Value of the piece to put in the pole, to compare to the last piece, to verify if it can be put in there)
This is how i make them:
and in anothe class i have:
public class Piece extends Actor { int valueId; boolean movable; public Piece(int valueId,String image) { GreenfootImage img = new GreenfootImage(image); this.setImage(img); this.valueId = valueId; } }
private void prepare() { Palo palo1 = new Palo(1); addObject(palo1, 150, 220); Palo palo2 = new Palo(2); addObject(palo2, 300, 220); Palo palo3 = new Palo(3); addObject(palo3, 450, 220); Pieza pieza1 = new Pieza(1,"1.png"); addObject(pieza1, 150, 220); Pieza pieza2 = new Pieza(2,"2.png"); addObject(pieza2, 150, 200); }
public boolean validaPush(Pieza pieza){ boolean returnValue; if(stackPieza.get(stackPieza.size()) != null && stackPieza.get(stackPieza.size()) > pieza.valueId){ returnValue = true; }else{ returnValue = false; } return returnValue; }