// Buggles that Harvest bagels. // CS111 Fall 2000 PS 6 import java.awt.*; public class HarvestWorld extends BagelBuggleWorld { public void run () { Harvester hannah = new Harvester(); hannah.brushUp(); resultField1.setText(Integer.toString(hannah.harvestField())); } } class Harvester extends Buggle { // This method asks the buggle to harvest each row of a field // and to return the number of bagels harvested. // This method meets the invariant that the buggle's state // (position, heading, color, and brush state) will // not be changed by execution of this method. // Assumes the buggle's brush is initially up. public int harvestField() { // Replace this stub. return 0; } // This method asks the buggle to harvest the row of bagels // to the left of the buggle and return the number of bagels // in this row. Harvesting involves the following steps: // --pick up and count all the bagels in the row // --put the bagels out to dry in a row starting from the bottom // but not including the very bottom row // --pulling the tarp over the rest of each row by walking to the // end of the row and coloring the row black until you've reached // the bagels // --marking the row as fair (no color), good (green), or bad (red) // by coloring the first (bottom) square of each row. // A row produced a good harvest if there are more bagels than // blank spots. A row produced a bad harvest if there are fewer // bagels than blank spots. // --marking the row by dropping the number of blank spots in the // bottom square. // This method meets the invariant that the buggle's state // (position, heading, color, and brush state) will // not be changed by execution of this method. // Assumes the buggle's brush is initially up. public int harvestRow() { // Replace this stub. return 0; } // This method picks up and counts the number of bagels // between the buggle and the wall in front and returns the // number of bagels. // This method meets the invariant that the buggle's state // (position, heading, color, and brush state) will // not be changed by execution of this method. // Assumes the buggle's brush is initially up. public int harvestBagels() { // Replace this stub. return 0; } // This method creates a stack of bagels in front of the buggle // with the specified number of bagels. This method assumes that // there will always be at least enough space in front of the buggle // for the bagel stack. // This method meets the invariant that the buggle's state // (position, heading, color, and brush state) will // not be changed by execution of this method. // Assumes the buggle's brush is initially up. public void stackBagels(int bagelCount) { // Flesh out this skeleton. } // This method draws a black line from the wall in front of the buggle // to the current cell in front of the buggle (ie do not color the cell // the buggle is on when the method is invoked). This method returns // the number of cells colored. // This method meets the invariant that the buggle's state // (position, heading, color, and brush state) will // not be changed by execution of this method. // Assumes the buggle's brush is initially up. public int pullTarp() { // Replace this stub. return 0; } // This method colors the cell the buggle is on green if // bagelCount is greater than spaceCount. // The cell is colored red if bagelCount is less than spaceCount. // The buggle also marks the cell with the spaceCount (using dropInt()). // This method meets the invariant that the buggle's state // (position, heading, color, and brush state) will // not be changed by execution of this method. // Assumes the buggle's brush is initially up. public void markRow(int bagelCount, int spaceCount) { // Flesh out this skeleton. } }