russellp
YaBB Newbies
Offline
Posts: 3
Object Array question
Mar 16th , 2010, 5:14am
Hi, I am trying to initialise and use an array of an object called Dice, for which I have created the following Class: class Dice { int face; float diceX, diceY, diceAngle; //constructor Dice (int f, float x, float y, float a) { this.face = f; this.diceX = x; this.diceY = y; this.diceAngle = a; } //methods public void setFace(int face){ this.face = face; } public int getFace(int face){ return face; } public void setdiceX(float diceX){ this.diceX = diceX; } public float getdiceX(float diceX){ return diceX; } public void setdiceY(float diceY){ this.diceY = diceY; } public float getdiceY(float diceY){ return diceY; } public void setdiceAngle(float diceAngle){ this.diceAngle = diceAngle; } public float getdiceAngle(float diceAngle){ return diceAngle; } } this appears to be fine, but as soon as I call one of the methods, I get an error. The setup() and a method to debug the code are below, but when run, I get an error "the function getFace() does not exist." void setup(){ size(1,1); noLoop(); TuioProcessing tuioClient = new TuioProcessing(this); //get an instance of MidiIO midiIO = MidiIO.getInstance(this); dice = new Dice[i]; for (int i=0; i< dice.length; i++) { //load dice details into array??? dice[i] = new Dice(tobj.getSymbolID(), tobj.getX(), tobj.getY(), tobj.getAngle() ); } } void readDice(Dice[]dice){ for (int i=0;i< dice.length; i++){ println(getFace()); } } What am I doing wrong in the Class? Thanks, Russell