.

Wednesday, February 5, 2014

Tma02 255

M255 Object-oriented programming with Java Tutor-marked assignment 02 2011J [pic] Q1 i) /** * Moves the frog to the st nonpareil whose aspect is prone one stone at * a date and returns no value */ world void moveToPosition(int pos) { int currentPosition = proceedPosition(); //ignore if ar already on the compulsory position if( pos != currentPosition) { //move one pervert at a time left field filename extension or right int step = 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 required position is met { i+=step; setPosition(i); } while(i != pos); // parallel until we are on required pos } //jump one time jump(); } } Test. Image of RacingFrog rf = forward-looking RacingFrog(); [pic] Image of rf.moveToPosition(7); [pic] Image of rf.moveToPosition(1); [pic] Q1 ii) a) commonplace class Race { /* eccentric variables */ tete-a-tete boolean washingOver; // indicates whether the race has been won private RacingFrog winner; // holds the winning travelFrog private haphazard randomGenerator; private RacingFrog racingFrog1; // holds the racing frog 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 class Race. */ public Race(RacingFrog rf1, Racin gFrog 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, visit our page: write my paper

No comments:

Post a Comment