location.java

来自「软件工程实践课程的答案哦」· Java 代码 · 共 93 行

JAVA
93
字号
/*
 * 
 * This class encapsulates all the data to signify 
 * the position and color of a square.
 */

public class Location {
	public int x;
	public int y;
	public int color;
	
	public Location()
	{
		this(-1,-1,-1);
	}
	
	public Location(int pX,int pY,int pColor)
	{
		this.x=pX;
		this.y=pY;
		this.color=pColor;
	}
	/**
	 * increase x by 1*/
	public void increaseX()
	{
		this.x++;
	}
	/**
	 * decrease x by 1*/
	public void decreaseX()
	{
		this.x=this.x-1;
	}
	/**
	 * increase y by 1*/
	public void increaseY()
	{
		this.y++;
	}
	/**
	 * decrease x by 1*/
	public void decreaseY()
	{
		this.y=this.y-1;
	}
	
	/**
	 * get and set color
	 */
	public int getColor()
	{
		return this.color;
	}
	
	public void setColor(int pColor)
	{
		this.color=pColor;
	}
	
	/**
	 * @return get and set x
	 */
	public int getX()
	{
		return this.x;
	}
	/**
	 * set atribute X
	 * @param pX the value to set*/
	public void setX(int pX)
	{
		this.x=pX;
	}
	
	/**
	 * @return get and set y
	 */
	public int getY()
	{
		return this.y;
	}
	/**
	 * set atribute Y
	 * @param pY the value to set*/
	public void setY(int pY)
	{
		this.y=pY;
	}
	
	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?