Complete and fully test the class Person that Exercise 10 describes. Include the following additional methods.
• getName—returns the name of the person as a string.
• getAge—returns the age of the person.
• setName(first, last)—sets the name of the person, given a first and last
name as strings.
• setName(name)—sets the name of the person, given the entire name as one string.
• setAge(age)—sets the age of the person.
• createToddler—a static method that returns a special instance of the class
to represent a toddler. The instance has the name “A toddler” and the age 2.
• createPreschooler—a static method that returns a special instance of the
class to represent a preschooler. The instance has the name “A preschooler”
and the age 5.
• createAdolescent—a static method that returns a special instance of the
class to represent an adolescent. The instance has the name “An adolescent”
and the age 9.
• createTeenager—a static method that returns a special instance of the class to represent a teenager. The instance has the name “A teenager” and the age 15.
This project demonstrates a class that uses static methods to create special instances of the class. Test cases are in the main method
See the code in Person.java.
You might also like to view...
Programming flag variables are used in programs for remembering states or conditions. What are the two best data types to use for flags? Give an example of a flag that remembers if a value is negative, zero or positive.
What will be an ideal response?
An evaluation model is a technique that uses a common yardstick to measure and compare vendor ratings.
Answer the following statement true (T) or false (F)