// **************************************************************** // Person.java // // A simple class representing a person. // *************************************************************** public class Person { private String name; private int age; // ------------------------------------------------------------ // Sets up a Person object with the given name and age. // ------------------------------------------------------------ public Person (String name, int age) { this.name = name; this.age = age; } // ------------------------------------------------------------ // Returns the name of the Person. // ------------------------------------------------------------ public String getName() { return name; } // ----------------------------------------------------------- // Returns the age of the Person. // ----------------------------------------------------------- public int getAge () { return age; } // ------------------------------------------------------------ // Changes the name of the Person to the parameter newName. // ------------------------------------------------------------ public void setName(String newName) { name = newName; } // ----------------------------------------------------------- // Changes the age of the Person to the parameter newAge. // ----------------------------------------------------------- public void setAge (int newAge) { age = newAge; } // ----------------------------------------------------------- // Returns the person's name and age as a string. // ----------------------------------------------------------- public String toString() { return name + " - Age " + age; } }