Quick Index
Problem Statement


Two challenges:


This challenge closely follows the example.

Also see the "Hints" page.

Getting Started


This challenge is a continuation of this work:


Recall that we previously coded these methods: moveToOrigin, move1, getX, getY.

Copy or add "Point.java" and "PointTests.java" to a new working directory for this challenge.

Point


Add (code) the following methods into the Point class (i.e., with completed the method bodies):

Method HeaderDescription
public void setX(int aValue)Set the instance variable (ivar) "x" to the param "aValue"
public void setY(int aValue)Set the ivar "y" to the param "aValue"
public void set(int aValue)Set ivars "x" and "y" to the param "aValue"
public void set(int aX, int aY)Set ivar "x" to param "aX" and set ivar "y" to param "aY"


PointTests


For this part of the challenge it will take some creativity.

You will extend your previous PointTests class.

The challenge is to write a test method for each of the new "Point" methods described above. We do not specify test method names here, which means it is "coder's choice". This is unlike the methods we add to Point (above), where the method headers are specified for us so we must match those exactly.

See Your New Test Methods for ideas

Construction of Point
In addition to the other listed tests, also make sure the code shown here works with your point class
Point point;
point = new Point();


toString


You start always adding toString to your classes. It's purpose is to help you debug code when needed.

It is a "loose" (free form) method with the purpose of returning a "nice display string".

For the "Point" class, you could copy and use this code:

	public String toString()  {
		//Return a "nice" display string
		return "" + x + " x " + y;
	}

getX and getY


Make sure the getter methods getX and getY are implemented in your Point class.

They can be carried forward (copied from previous assignment) or re-coded, whichever is needed.

Grading


For this assignment, we will use these grading rules.