first commit
This commit is contained in:
214
CS1322/p6/Krystian/GamePiece.java
Normal file
214
CS1322/p6/Krystian/GamePiece.java
Normal file
@@ -0,0 +1,214 @@
|
||||
/**
|
||||
* CS1322: Programming Assignment #6 - Fall 2002
|
||||
*
|
||||
* <PRE>
|
||||
* IDBox for: GamePiece.java
|
||||
*
|
||||
* Revisions: 1.0 Nov. 21, 2002
|
||||
* Created the GamePiece 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. 21, 2002
|
||||
*/
|
||||
|
||||
// imports are listed above IDBox
|
||||
|
||||
/**
|
||||
* MODEL.
|
||||
* GamePiece. GamePiece is abstract.
|
||||
* This class is the super class to all pieces of the game board.
|
||||
*/
|
||||
|
||||
public abstract class 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 GamePiece.
|
||||
* @param void No parameters.
|
||||
* @return GamePiece instance/object.
|
||||
*
|
||||
public GamePiece()
|
||||
{
|
||||
|
||||
} //end of GamePiece()
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructor 2. Specified default-overloading constructor for GamePiece.
|
||||
* @param x the location along the x-axis.
|
||||
* @param y the location along the y-axis.
|
||||
* @return GamePiece instance/object.
|
||||
*/
|
||||
public GamePiece( int x, int y )
|
||||
{
|
||||
this.setPosition(x,y);
|
||||
} //end of GamePiece(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 GamePiece.
|
||||
* @return boolean whether objects are equal.
|
||||
*
|
||||
public boolean equals (Object o)
|
||||
{
|
||||
|
||||
} //end of equals(Object)
|
||||
*/
|
||||
|
||||
/**
|
||||
* toString instance printer. Prints properties of GamePiece.
|
||||
* @return System.out.println(GamePiece instance) instance print.
|
||||
*
|
||||
public String toString()
|
||||
{
|
||||
|
||||
} //end of toString()
|
||||
*/
|
||||
|
||||
/*
|
||||
// =======================================================================
|
||||
// Class specific methods local to this instance
|
||||
// =======================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* setPosition. Sets the location variables to passed in x,y parameters.
|
||||
* @param x the new location along the x-axis.
|
||||
* @param y the new location along the y-axis.
|
||||
*/
|
||||
public void setPosition( int x, int y )
|
||||
{
|
||||
this.setX(x);
|
||||
this.setY(y);
|
||||
} //end of setPosition(int, int)
|
||||
|
||||
|
||||
/*
|
||||
// =======================================================================
|
||||
// Methods dealing directly with the data within this instance
|
||||
// (accessors, modifiers, etc)
|
||||
// =======================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the value of x.
|
||||
* @return value of x.
|
||||
*/
|
||||
public int getX()
|
||||
{
|
||||
return x;
|
||||
} //end of getX()
|
||||
|
||||
/**
|
||||
* Set the value of x.
|
||||
* @param v Value to assign to x.
|
||||
*/
|
||||
public void setX(int v)
|
||||
{
|
||||
this.x = v;
|
||||
} //end of setX(int)
|
||||
|
||||
/**
|
||||
* Get the value of y.
|
||||
* @return value of y.
|
||||
*/
|
||||
public int getY()
|
||||
{
|
||||
return y;
|
||||
} //end of getY()
|
||||
|
||||
/**
|
||||
* Set the value of y.
|
||||
* @param v Value to assign to y.
|
||||
*/
|
||||
public void setY(int v)
|
||||
{
|
||||
this.y = v;
|
||||
} //end of setY(int)
|
||||
|
||||
|
||||
/*
|
||||
// =======================================================================
|
||||
// Private/Protected Variables local to this instance
|
||||
// =======================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Together these two variables represent the exact location of the
|
||||
* board this particular piece is in. The location (0,0) is the
|
||||
* upper left hand corner of the game board.
|
||||
*/
|
||||
|
||||
/**
|
||||
* x. Column placeholder.
|
||||
* This variable represents which column the piece is in.
|
||||
* i.e., it's location along the x-axis.(the top edge of the screan)
|
||||
*/
|
||||
protected int x;
|
||||
|
||||
/**
|
||||
* y. Row placeholder.
|
||||
* This variable representswhich row the piece is in.
|
||||
* i.e., it's location along the y-axis. (the side edge of the screan)
|
||||
*/
|
||||
protected int y;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// =======================================================================
|
||||
// Main method (overrides this commenting system for readibility reasons)
|
||||
// =======================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Debugging main for class GamePiece.
|
||||
* 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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (DEBUG) System.out.println("end main(String[] args) call:");
|
||||
} //end of DEBUG if
|
||||
|
||||
} //end of main(String[] args)
|
||||
|
||||
} //end of class GamePiece
|
||||
Reference in New Issue
Block a user