import java.awt.*; /* CS111 Lab 2 Drawing a multicolored checkerboard using methods Wendy Wellesley CS111 */ public class BigChecksboard extends BuggleWorld { int n=15; public void setup() { setDimensions(n,n); } // setup() public void run () { // create dude who draws the multicolored checkerboard CheckerBuggle dude = new CheckerBuggle(); dude.drawBoard(); } // run() } // class BigChecksboard class CheckerBuggle extends Buggle { // drawBoard draws the entire board and sets the buggle back to the center of the board public void drawBoard(){ this.drawRow(); this.moveToNewRow(); this.drawRow(); this.moveToNewRow(); this.drawRow(); this.moveToCenter(); } // drawBoard() // moveToCenter moves the buggle from the end of a row to the center of the board public void moveToCenter() { this.brushUp(); this.backward(3); this.left(); this.backward(3); } // moveToCenter() // drawRow draws one row of the board, which consists of 3 blocks public void drawRow() { drawBlock(); scoot(); drawBlock(); scoot(); drawBlock(); } // drawRow() // scoot moves the buggle to the starting position to draw a block public void scoot() { this.brushUp(); this.forward(5); this.brushDown(); } // scoot() // moveToNewRow moves the buggle from the end of one row to the start of the next one public void moveToNewRow() { this.brushUp(); this.left(); this.forward(5); this.left(); this.forward(10); this.right(); this.right(); this.brushDown(); } // moveToNewRow() // drawBlock draws one block of the board public void drawBlock() { this.setColor(Color.red); this.drawPattern(); this.setColor(Color.blue); this.drawPattern(); this.setColor(Color.yellow); this.drawPattern(); this.setColor(Color.black); this.drawPattern(); } // drawBlock() // drawPattern draws one step pattern public void drawPattern () { this.brushUp(); this.forward(); this.brushDown(); this.forward(); this.brushUp(); this.left(); this.forward(); this.brushDown(); this.backward(); this.right(); this.brushUp(); this.forward(); this.brushDown(); this.forward(); this.left(); } // drawPattern() } // class CheckerBuggle