import java.awt.*; public class CheckerBuggle extends Buggle { /*************************************** * CheckerBoard by Rows ****************************************/ public void makeCheckerBoardRows () { this.twoF(); this.draw2RowsTurn(); this.draw2RowsTurn(); this.draw2RowsTurn(); this.draw2Rows(); this.twoL(); } // this method draws six squares to the right, // makes a U-turn and draws six squares to the left void draw2Rows () { this.fourF(); this.rightCorner(); this.fourF(); } // this method draws the 2 rows above and then adds // the U-turn at the left of the board void draw2RowsTurn () { this.draw2Rows(); this.leftCorner(); } /*************************************** * CheckerBoard by Squares ****************************************/ public void makeCheckerBoardSquare () { this.twoColumns(); this.skip2(); this.twoColumns(); } // this method draws a square // and ends in a position ready to draw the next square void backwardC () { this.twoL(); this.left(); this.twoR(); this.right(); } // this method draws a square // and ends in a position on itself void backwardCx () { this.twoL(); this.left(); this.blackF(); this.setColor(Color.red); this.backward(); } // this method draws a vertical column of squares void column() { this.backwardC(); this.backwardC(); this.backwardC(); this.backwardCx(); } // this method draws two vertical columns of squares void twoColumns() { this.column(); this.brushUp(); this.backward(2); this.brushDown(); this.column(); } /*************************************** * CheckerBoard by Ls ****************************************/ public void makeCheckerBoardL () { this.halfBoard(); this.skip1(); this.left(); this.skip2(); this.skip2(); this.skip2(); this.skip1(); this.left(); this.halfBoard(); } // this method draws two L Shapes which together form // a 2 by 4 rectangle on the checkerboard void twoLShapes () { this.LShape(); this.left(); this.LShape(); this.left(); } // this method draws half of the CheckerBoard void halfBoard () { this.twoLShapes(); this.skip2(); this.twoLShapes(); this.skip2(); this.twoLShapes(); this.skip2(); this.twoLShapes(); } /*************************************** * CheckerBoard by Spiral ****************************************/ public void makeCheckerBoardSpiral () { this.twoF(); this.fourF(); this.redCorner(); this.fourF(); this.blackCorner(); this.fourF(); this.redCorner(); this.twoF(); this.redCorner(); this.twoF(); this.redCorner(); this.twoF(); this.blackCorner(); this.twoF(); this.redCorner(); this.redCorner(); this.redCorner(); this.blackCorner(); this.twoL(); this.twoL(); this.twoL(); this.left(); this.twoF(); } // this method turns the corner where the corner is red void redCorner() { this.LShape(); } // this method turns the corner where the corner is black void blackCorner() { this.left(); this.twoF(); } /*************************************** * CheckerBoard by Maze ****************************************/ public void makeCheckerBoardMaze () { this.twoL(); this.left(); this.leftCorner(); this.innerCornerR(); this.bottomCorner(); this.innerCornerL(); this.leftCorner(); this.twoF(); this.innerCornerR(); this.twoF(); this.bottomCorner(); this.twoF(); this.innerCornerL(); this.twoF(); this.leftCorner(); this.twoF(); this.twoF(); this.innerCornerR(); this.twoF(); this.twoF(); this.bottomCorner(); this.twoF(); this.twoF(); this.innerCornerL(); this.twoF(); this.twoF(); this.twoL(); } // this method turns the corner along the center diagonal // of the checkerboard as you approach the corner going right void innerCornerR() { this.right(); this.twoF(); } // this method turns the corner along the bottom edge // of the checkerboard void bottomCorner() { this.left(); this.twoL(); this.twoF(); } // this method turns the corner along the center diagonal // of the checkerboard as you approach the corner going left (north) void innerCornerL() { this.left(); this.twoF(); } /*************************************** * Methods to move the CheckerBuggle ****************************************/ // paint a black color and move forward void blackF () { this.setColor(Color.black); this.forward(); } // paint a red color and move forward void redF() { this.setColor(Color.red); this.forward(); } // paint a red color and move to the left void redL() { this.left(); this.redF(); } // paint a red color and move to the right void redR() { this.right(); this.redF(); } // move in a unit of two squares // the first square is painted black // the second square is painted red // end in the same direction as original heading void twoF() { this.blackF(); this.redF(); } // move two sets of two squares forward // black, red, black, red void fourF() { this.twoF(); this.twoF(); } // move in a unit of two squares (black, red) // end on the square to the left of the red square // facing left relative to original heading void twoL() { this.blackF(); this.redL(); } // move in a unit of two squares (black, red) // end on the square to the right of the red square // facing right relative to original heading void twoR() { this.blackF(); this.redR(); } // paints the U-turn as one approaches the left side // of the checkerboard void leftCorner() { this.twoR(); this.right(); this.twoF(); } // paints the U-turn as one approaches the right side // of the checkerboard void rightCorner() { this.twoL(); this.left(); this.twoF(); } // paints the L shape void LShape() { this.twoL(); this.twoF(); } // go forward one square without painting a color void skip1() { this.brushUp(); this.forward(); this.brushDown(); } // go forward two squares without painting a color void skip2() { this.brushUp(); this.forward(2); this.brushDown(); } }