EECS 1030 Z, Summer 2015

Person

 

Your Task

Create a class named "Person", that implementes this API. Start with the code below and write the Javadoc and methods as listed in the API.

Generate your Javadoc and compare your Javadoc with the provided one. They should be exactly the same.

Use the following code to create a class named "PersonTester":

public class PersonTester
{
	public static void main(String[] args)
	{
		Person p1 = new Person("Jane Doe", 32, "321-555-1234");
		Person p2 = new Person("Aaron Wu", 28, "awu@mail.com");
		// Create additional Person objects as needed.
		
		// Test toString
		System.out.print("Testing toString...");
		if (p1.toString().equals("Jane Doe, age: 32, contact: 321-555-1234"))
		{
			System.out.println("passed\n");
		}
		else
		{
			System.out.println("failed\n");
		}
		
		// Test compareTo
		System.out.print("Testing compareTo...");
		boolean result = p1.compareTo(p1) == 0;
		result &= p1.compareTo(p2) > 0;
		result &= p2.compareTo(p1) < 0;
		if (result)
		{
			System.out.println("passed\n");
		}
		else
		{
			System.out.println("failed\n");
		}
		
		// Add and implement other tests as needed...
		;
		
	}
}
Use this code to test your Person class. Ensure that you what this code does and how it works.

 

 

 

--- End of Exercise ---