import java.awt.*; /* CS111 Lab 2: Writing Java Methods - Task 4: SuperBigChecksboard FILE NAME: SuperBigChecksboard.java AUTHOR NAME: Stella WHEN: Aug 24, 2007 COMMENTS: MODIFICATION HISTORY: */ public class SuperBigChecksboard extends BuggleWorld { public void setup() { setDimensions(45,45); } public void run () { CheckerBuggle cheek = new CheckerBuggle(); //cheek.drawSuperBigRow(); //test it here, then comment it out //cheek.positionForNewSuperBigRow(); cheek.drawAllSuperBigRows(); cheek.positionFinalSuperBig(); } // run() //------------------------------------------------------------------------------ // The following main method is needed to run the applet as an application public static void main (String[] args) { runAsApplication(new SuperBigChecksboard(), "SuperBigChecksboard"); } } // class SuperBigChecksboard class CheckerBuggle extends Buggle { //draw 9 super big rows, i.e. the whole super big board public void drawAllSuperBigRows() { drawSuperBigRow(); positionForNewSuperBigRow(); drawSuperBigRow(); positionForNewSuperBigRow(); drawSuperBigRow(); positionForNewSuperBigRow(); drawSuperBigRow(); positionForNewSuperBigRow(); drawSuperBigRow(); positionForNewSuperBigRow(); drawSuperBigRow(); positionForNewSuperBigRow(); drawSuperBigRow(); positionForNewSuperBigRow(); drawSuperBigRow(); positionForNewSuperBigRow(); drawSuperBigRow(); } //position the buggle to the center of the super big board public void positionFinalSuperBig(){ setColor(Color.black); brushUp(); backward(18); //this 18 may need to change; not sure if buggle is at the very center left(); backward(18); //this 18 may need to change } //Position the drawing buggle at the right place to start drawing the next //super big row. public void positionForNewSuperBigRow() { brushUp(); backward(40); left(); forward(5); right(); setColor(Color.red); } //one row contains 9 patterns, each made of 4-triangles (one of each color). //for task 4 public void drawSuperBigRow() { drawOneRow(); brushUp(); forward(5); setColor(Color.red); brushDown(); drawOneRow(); brushUp(); forward(5); setColor(Color.red); brushDown(); drawOneRow(); } //Position the drawing buggle at the center of the final Bigboard public void positionFinal(){ setColor(Color.black); brushUp(); backward(3); left(); backward(3); } //Position the drawing buggle at the right place to start drawing the next //row: 5th row above and 10th column back public void positionForNewRow() { brushUp(); backward(10); left(); forward(5); right(); setColor(Color.red); } public void drawOneRow() { //one row contains 3 patterns, each made of 4-triangles (one of each color). draw4Triangles(); brushUp(); forward(5); brushDown(); setColor(Color.red); draw4Triangles(); brushUp(); forward(5); brushDown(); setColor(Color.red); draw4Triangles(); setColor(Color.red); } public void drawOneTriangle () { //debugging statement below prints to console //System.out.println("Just inside drawOneTriangle method"); brushUp(); forward(); brushDown(); forward(); brushUp(); left(); forward(); brushDown(); backward(); right(); brushUp(); forward(); brushDown(); forward(); left(); //debugging statement below prints to console window //System.out.println("About to leave drawOneTriangle method"); } // drawOneTriangle() /*public void draw3Rows() { draw1Row(); positionForNewRow(); draw1Row(); positionForNewRow(); draw1Row(); } */ public void draw4Triangles() { drawOneTriangle(); setColor(Color.blue); drawOneTriangle(); setColor(Color.yellow); drawOneTriangle(); setColor(Color.black); drawOneTriangle(); } //Draw one little triangle public void drawOneTriangle() { //System.out.println("inside CheckerWorld's drawTriangle method"); brushUp(); forward(); brushDown(); forward(); brushUp(); left(); forward(); brushDown(); backward(); right(); brushUp(); forward(); brushDown(); forward(); left(); } }