PersonTester - / // // f) Increase the age of person1 by 2....

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************* // PersonTester.java // // // A client to test the functionality of objects // of the class Person // //******************************************************* public class PersonTester{ p public static void main(String[] args) { // a) / // Declare a Person class type variable person1. // Declare a Person class type variable person2. // Declare a Person class type variable person3. / // b) Create a Person object whose name is "Marcus Smith" and age 23 and // assign it to the class type variable person1. / // c) Create a second Person object whose name "Mary Brown" and age 21 and assign it // to the class type variable person2. / // d) Use the method toString to display the two Person objects. System.out.println("person1=" + person1); System.out.println("person2=" + person2); S // e) Test whether person1 is older than 21 and display a message // to indicate whether person1 is or is not greater than 21.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: / // // f) Increase the age of person1 by 2. Hint: Use getAge to obtain the age // then use setAge to set the new age. // / // g) Display the current age of person1. / // h) Set the age of person2 to -12. / // i) Display the age of person2. / // j) Display a message that indicates whether or not person1 has the same name as person2. s // k) Display a message that indicates whether or not person1 is younger than person2, // older than person2 or they have the same age. / // l) Create a Person object whose name is "Marcus Brown" and age 25 and assign it // to the class type variable person3. / // m) Use the method setName to assign the name "Marcus Smith" to the Person object referred via person3. P // n) Display a message indicating whether person3 is equal to person1. / // o) Use the method setName to set the name of person3 to null. / person3.setName(null); p // p) Display the name of person3. / } }...
View Full Document

This note was uploaded on 11/15/2010 for the course CSCI 01209 taught by Professor Storm during the Fall '10 term at University of Georgia Athens.

Page1 / 2

PersonTester - / // // f) Increase the age of person1 by 2....

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online