Compile Issues


Here is case that some code that had some compile issues. Let's walk through it.

Original Code (Student Code)
Here is the original code (the code that has bugs that we are diagnosing).

The compiler is barking at us about the highlighted line "test.getX()", telling us that "test" does not understand "getX".
public void testMoveToOrigin() {

	PointTests test;

	test.testMoveToOrigin();

	System.out.println("--  testMoveToOrigin  --");
	System.out.println("Expected x: " + 0);
	System.out.println("Expected y: " + 0);

	println("Actual x: " + test.getX());
	println("Actual y: " + test.getY());
}
Reference Example
Let's reference the provided example, we'll put the code and example side-by-side.


//Example for class RectangleTests

public void testSetSmall()  {

	Rectangle rec;

	rec = new Rectangle();

	rec.setSmall();

	System.out.println("-- testSetSmall --");
	System.out.println("Expected Width: " + 5);
	System.out.println("Expected Height: " + 1);
	System.out.println("Actual Width: " + rec.getWidth());
	System.out.println("Actual Height: " + rec.getHeight());
}
//Our code for class PointTests (code with bugs)

public void testMoveToOrigin() {

	PointTests test;

	test.testMoveToOrigin();

	System.out.println("--  testMoveToOrigin  --");
	System.out.println("Expected x: " + 0);
	System.out.println("Expected y: " + 0);

	println("Actual x: " + test.getX());
	println("Actual y: " + test.getY());
}




Fixups
If we fixup our code using the identified differences, we'll be well on our way