/** * CS1322: Programming Assignment #6 - Fall 2002 * *
* IDBox for: FloorPiece.java * * Revisions: 1.0 Nov. 21, 2002 * Created the FloorPiece class * ** * Collaboration statement: * "I worked on the homework assignment alone, using only * course materials." * * @author Roland Krystian Alberciak * @version Version 1.0, Nov. 21, 2002 */ // imports are listed above IDBox /** * MODEL. * Floorpiece. Floorpiece extends GamePiece. * Adds the functionality of nibbles (The dots that Pacman eats). * Each FloorPiece can have a regular nibble, a special nibble * (one that allows Pacman to chase the ghosts), * or neither (but not both). */ public class FloorPiece extends GamePiece { /** Debug value for toggling System.out.* output */ public static boolean DEBUG = false; public static boolean DEBUG_MAIN = false; /* // ======================================================================= // Constructors // ======================================================================= */ /** * Constructor 1. Specified default-overriding constructor for FloorPiece. * @param void No parameters. * @return FloorPiece instance/object. * public FloorPiece() { } //end of FloorPiece() */ /** * Constructor 2. Specified default-overloading constructor for FloorPiece. * Takes in the location and storage of a FloorPiece::GamePiece object * @param x the location along the x-axis. * @param y the location along the y-axis. * @param hasNibble whether this FloorPiece should have a nibble * @param hasSpecial whether this FloorPiece should have a special * @return FloorPiece instance/object. */ public FloorPiece(int x, int y, boolean hasNibble, boolean hasSpecial) { // STUB //if then for if both are true? override with hasSpecial=true; super(x,y); //Chains to the super constructor. (GamePiece) this.setNibble(hasNibble); this.setSpecial(hasSpecial); } //end of FloorPiece(int, int, boolean, boolean) /* // ======================================================================= // Methods which override class Object methods // ======================================================================= */ /** * Equal instance comparison. Compares if two instances are equal. * @param o object-type reference of (hopefully) an FloorPiece. * @return boolean whether objects are equal. * public boolean equals (Object o) { } //end of equals(Object) */ /** * toString instance printer. Prints properties of FloorPiece. * @return System.out.println(FloorPiece instance) instance print. */ public String toString() { String result=""; if ( (getNibble()==false) && (getSpecial()==false) ) result= P6Constants.FLOOR; else if ( (getNibble()==true) && (getSpecial()==false) ) result= P6Constants.NIBBLE; else if ( (getNibble()==false) && (getSpecial()==true) ) result= P6Constants.SPECIAL; else //if ( (getNibble()==true) && (getSpecial()==true) ) result= "E"; //for error. Flag to programmer. result = result+" "; //cleanup, autoprepare for output return result; } //end of toString() /* // ======================================================================= // Class specific methods local to this instance // ======================================================================= */ /* // ======================================================================= // Methods dealing directly with the data within this instance // (accessors, modifiers, etc) // ======================================================================= */ /** * Get the value of hasNibble. * @return value of hasNibble. */ public boolean getNibble() { return hasNibble; } /** * Set the value of hasNibble. * @param v Value to assign to hasNibble. */ public void setNibble(boolean v) { this.hasNibble = v; } /** * Get the value of hasSpecial. * @return value of hasSpecial. */ public boolean getSpecial() { return hasSpecial; } /** * Set the value of hasSpecial. * @param v Value to assign to hasSpecial. */ public void setSpecial(boolean v) { this.hasSpecial = v; } /* // ======================================================================= // Private Variables local to this instance // ======================================================================= */ /** * hasNibble. Whether floorpiece has a regular nibble. * Represents whether or not this FloorPiece has a nibble that Pacman eats * (the regular ones, not the ones that lets Pacman chase Ghosts) */ private boolean hasNibble; /** * hasSpecial. Whether floorpiece has a special nibble. * Represents whether or not this FloorPiece has a special nibble * (the special ones which allows Pacman to chase Ghosts.) */ private boolean hasSpecial; /* // ======================================================================= // Main method (overrides this commenting system for readibility reasons) // ======================================================================= */ /** * Debugging main for class FloorPiece. * This method will rigorously test my code. * *