public class Lab2 { public static void cleanSquare() { Robot.load("square.txt"); Robot.setDelay(0.1); Lab2.makeLineLight(); Lab2.moveAndTurn(); Lab2.makeLineLight(); Lab2.moveAndTurn(); Lab2.makeLineLight(); Lab2.moveAndTurn(); Lab2.makeLineLight(); Lab2.moveAndTurn(); } public static void makeLineLight() { // Precondition: Robot is facing a light line of // 6 light cells. Lab2.makeCellLight(); Lab2.makeCellLight(); Lab2.makeCellLight(); Lab2.makeCellLight(); Lab2.makeCellLight(); } public static void makeCellLight() { // Precondition: Robot is in front of a dark cell Robot.move(); Robot.makeLight(); } public static void moveAndTurn() { // Precondition: Robot is in front of a corner cell // of the square. Robot.move(); Robot.turnLeft(); } public static void darkenComb() { Robot.load("comb.txt"); Robot.setDelay(0.05); Lab2.darkenOneCombFinger(); Lab2.returnToLeft(); Lab2.advanceToNextFinger(); Lab2.darkenOneCombFinger(); Lab2.returnToLeft(); Lab2.advanceToNextFinger(); Lab2.darkenOneCombFinger(); Lab2.returnToLeft(); Lab2.advanceToNextFinger(); Lab2.darkenOneCombFinger(); Lab2.returnToLeft(); Lab2.advanceToNextFinger(); Lab2.darkenOneCombFinger(); Lab2.returnToLeft(); } public static void darkenOneCombFinger() { // Precondition: Robot is facing right on a light cell // and is looking at a row of 6 light squares Robot.makeDark(); Lab2.turnRobotRight(); Lab2.makeCellDark(); Lab2.makeCellDark(); Lab2.makeCellDark(); Lab2.makeCellDark(); Lab2.makeCellDark(); Lab2.makeCellDark(); } public static void makeCellDark() { // Precondition: Robot is in front of a light cell Robot.move(); Robot.makeDark(); } public static void returnToLeft() { // Precondition: Robot is at the right end // of a line of 7 dark cells, facing right Lab2.turnRobotAround(); Robot.move(); Robot.move(); Robot.move(); Robot.move(); Robot.move(); Robot.move(); Lab2.turnRobotRight(); } public static void advanceToNextFinger() { // Precondition: Robot is facing up and has 2 // light cells in front of it Robot.move(); Robot.makeDark(); Robot.move(); } public static void makeCheckered() { Robot.load("blank.txt"); Robot.setDelay(0.05); Lab2.makeCheckeredColumn(); Lab2.turnRightToNextColumn(); Lab2.makeCheckeredColumn(); Lab2.turnLeftToNextColumn(); Lab2.makeCheckeredColumn(); Lab2.turnRightToNextColumn(); Lab2.makeCheckeredColumn(); Lab2.turnLeftToNextColumn(); Lab2.makeCheckeredColumn(); Lab2.turnRightToNextColumn(); Lab2.makeCheckeredColumn(); Lab2.turnLeftToNextColumn(); Lab2.makeCheckeredColumn(); Lab2.turnRightToNextColumn(); Lab2.makeCheckeredColumn(); } public static void makeCheckeredColumn() { // Precondition: Robot is facing a completely clear column Lab2.makeCheckeredPair(); Lab2.makeCheckeredPair(); Lab2.makeCheckeredPair(); Robot.makeDark(); Robot.move(); } public static void makeCheckeredPair() { // Precondition: Robot has at least two light // cells directly in front of it Robot.makeDark(); Robot.move(); Robot.move(); } public static void turnRightToNextColumn() { // Precondition: Robot is facing the edge at the // top of a column and the column to the right // is completely light. Lab2.turnRobotRight(); Robot.move(); Lab2.turnRobotRight(); } public static void turnLeftToNextColumn() { // Precondition: Robot is facing the edge at the // bottom of a column and the column to the right // is completely light. Robot.turnLeft(); Robot.move(); Robot.turnLeft(); } public static void turnRobotRight() { Robot.turnLeft(); Robot.turnLeft(); Robot.turnLeft(); } public static void turnRobotAround() { Robot.turnLeft(); Robot.turnLeft(); } }