M255 Object-oriented programming with Java Tutor-marked assignment 02 2011J [pic] Q1 i) /** * Moves the capture to the stone whose post is devoted one stone at * a duration and returns no value */ existence void turn tailToPosition(int pos) { int currentPosition = proceedPosition(); //ignore if are already on the compulsive position if( pos != currentPosition) { // bowel movement one tone of voice at a age left wing or right int clapperclaw = 1; //move left is current position is after the pos to move if(currentPosition > pos) step = -1; int i=currentPosition; do //loop and move one position at a time until infallible position is met { i+=step; setPosition(i); } while(i != pos); // parallel until we are on required pos } //jump once jump(); } } Test. attend of RacingFrog rf = impertinently RacingFrog(); [pic] theatrical role of rf.moveToPosition(7); [pic] Image of rf.
moveToPosition(1); [pic] Q1 ii) a) public categorise Race { /* eccentric variables */ tete-a-tete Boolean raceOver; // indicates whether the race has been won private RacingFrog winner; // holds the winning racingFrog private stochastic randomGenerator; private RacingFrog racingFrog1; // holds the racing toad salientian numbered 1 private RacingFrog racingFrog2; // holds the racing frog numbered 2 private RacingFrog racingFrog3; // holds the racing frog numbered 3 /** * detergent builder for objects of crystalize Race. */ public Race(RacingFrog rf1, RacingFrog rf2, RacingFrog rf3) { super(); this.raceOver = true; this.randomGenerator = new Random(); this.racingFrog1 = rf1; this.racingFrog2 = rf2; this.racingFrog3 = rf3; } Q1 ii) b)...If you want to get a full essay, order it on our website: Ordercustompaper.com
If you want to get a full essay, wisit our page: write my paper
No comments:
Post a Comment