first commit
This commit is contained in:
189
CS1322/p6/Krystian/Pacman.java
Normal file
189
CS1322/p6/Krystian/Pacman.java
Normal file
@@ -0,0 +1,189 @@
|
||||
/**
|
||||
* CS1322: Programming Assignment #6 - Fall 2002
|
||||
*
|
||||
* <PRE>
|
||||
* IDBox for: Pacman.java
|
||||
*
|
||||
* Revisions: 1.0 Nov. 23, 2002
|
||||
* Created the Pacman class
|
||||
*
|
||||
* </PRE>
|
||||
*
|
||||
* Collaboration statement:
|
||||
* "I worked on the homework assignment alone, using only
|
||||
* course materials."
|
||||
*
|
||||
* @author
|
||||
<A HREF="mailto:gtg142g@mail.gatech.edu">Roland Krystian Alberciak</A>
|
||||
* @version Version 1.0, Nov. 23, 2002
|
||||
*/
|
||||
|
||||
// imports are listed above IDBox
|
||||
|
||||
|
||||
/**
|
||||
* MODEL.
|
||||
* Pacman. Pacman extends MoveablePiece.
|
||||
* This class will model the Pacman piece which the user will control.
|
||||
*/
|
||||
|
||||
public class Pacman extends MoveablePiece
|
||||
{
|
||||
/** Debug value for toggling System.out.* output */
|
||||
public static boolean DEBUG = false;
|
||||
public static boolean DEBUG_CODE = false;
|
||||
public static boolean DEBUG_MAIN = false;
|
||||
|
||||
|
||||
/*
|
||||
// =======================================================================
|
||||
// Constructors
|
||||
// =======================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructor 1. Specified default-overriding constructor for Pacman.
|
||||
* @param void No parameters.
|
||||
* @return Pacman instance/object.
|
||||
*
|
||||
public Pacman()
|
||||
{
|
||||
|
||||
} //end of Pacman()
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructor 2. Specified default-overloading constructor for Pacman.
|
||||
* Takes in the location of the Pacman::MoveablePiece::GamePiece.
|
||||
* @param x the location along the x-axis.
|
||||
* @param y the location along the y-axis.
|
||||
* @return Pacman instance/object.
|
||||
*/
|
||||
public Pacman(int x, int y)
|
||||
{
|
||||
super(x,y); //Chains to the super constructor. (MoveablePiece)
|
||||
} //end of Pacman(int, int)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// =======================================================================
|
||||
// Methods which override class Object methods
|
||||
// =======================================================================
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Equal instance comparison. Compares if two instances are equal.
|
||||
* @param o object-type reference of (hopefully) an Pacman.
|
||||
* @return boolean whether objects are equal.
|
||||
*
|
||||
public boolean equals (Object o)
|
||||
{
|
||||
|
||||
} //end of equals(Object)
|
||||
*/
|
||||
|
||||
/**
|
||||
* toString instance printer. Prints properties of Pacman.
|
||||
* @return System.out.println(Pacman instance) instance print.
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
String result="";
|
||||
|
||||
result = "I am Pacman!! located at (x,y): (" +getX()+", "+getY()+")";
|
||||
|
||||
return result;
|
||||
} //end of toString()
|
||||
|
||||
|
||||
/*
|
||||
// =======================================================================
|
||||
// Class specific methods local to this instance (ex: forced by interface)
|
||||
// =======================================================================
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
// =======================================================================
|
||||
// Methods dealing directly with the data within this instance
|
||||
// (accessors, modifiers, etc)
|
||||
// =======================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the value of direction.
|
||||
* @return value of direction.
|
||||
*/
|
||||
public int getDirection()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of direction.
|
||||
* @param v Value to assign to direction.
|
||||
*/
|
||||
public void setDirection(int v)
|
||||
{
|
||||
this.direction = v;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// =======================================================================
|
||||
// Protected Variables local to this instance
|
||||
// =======================================================================
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
// =======================================================================
|
||||
// Private Variables local to this instance
|
||||
// =======================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* direction. Contain one of the four constants from P6Constants:
|
||||
* NORTH, EAST, SOUTH, WEST.
|
||||
* Represents the direction Pacman is currently heading on the board.
|
||||
* This variable is by default initialized to EAST.
|
||||
*/
|
||||
private int direction = P6Constants.EAST;
|
||||
|
||||
/*
|
||||
// =======================================================================
|
||||
// Main method (overrides this commenting system for readibility reasons)
|
||||
// =======================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Debugging main for class Pacman.
|
||||
* This method will rigorously test my code.
|
||||
*
|
||||
* <br><br>
|
||||
* @param args a String array of command line arguments.
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
|
||||
if ( (args.length==1) && (args[0].equals("-db") ) )
|
||||
DEBUG_MAIN=true; //else leave false: ignore input.
|
||||
|
||||
if (DEBUG_MAIN)
|
||||
{ // NOTE: This {} encapsulates most of main and is leftmost margin as a flag.
|
||||
// redundant ifs left in, in case the main if(DEBUG) statement was ommitted,
|
||||
// this would then print out neat output, as an example of real running.
|
||||
|
||||
Pacman pm = new Pacman(2,6);
|
||||
|
||||
System.out.println(pm);
|
||||
|
||||
|
||||
if (DEBUG) System.out.println("end main(String[] args) call:");
|
||||
} //end of DEBUG if
|
||||
|
||||
} //end of main(String[] args)
|
||||
|
||||
} //end of class Pacman
|
||||
Reference in New Issue
Block a user