CMPU 102 Lab 3: Creating and using a simple instantiable class February 13th, 2017 Part I: Creating a class to represent a person 1. Log in to your CS account and change directory to cs102. 2. Change directory into your labs subdirectory. 3. Create a new directory in your labs directory for lab 3 by entering: mkdir lab3 4. Write a class to represent the physical entity we call a person. Call the class Person and the file Person.java a) Define the following instance members in class Person: fullName (String) age (int) gender (char) idNumber (int) b) Define the following class member: static int counter = 9000; c) Define a 3-parameter constructor for your Person class that will initialize the fullName, age, and gender instance members by setting them equal to three input parameters. It is only necessary to include a single constructor in this class. Inside the constructor, increment the static counter variable and set the idNumber instance variable to the value of the counter after incrementing the counter. This will assign each Person object you created a different numeric value starting with 9001 and increasing in the order in which the objects are created. d) Create public getter methods for data fields 1 through 4. Call these methods getFullName(), getAge(), getGender(), and getIDNumber(). They should each return the value of the field type they refer to. e) Lastly, create a public method called "toString" that takes no input and returns a concatenated String representation of all the data members. The String returned by the toString() method should look something like this (use the tab escape sequence (\t) for tabs between data fields): Person 1: Harvey Jones 14 M // note: 4 variable names are used in this output, // concatenated with "Person " and ": " in the indicated // positions. NOTE: COMPILE AND SAVE OFTEN. YOU WILL NOT BE ABLE TO RUN THE PERSON.JAVA FILE UNTIL AFTER YOU FINISH PART II. ////////////////////////////////////////////////////////////////////// Part II: Testing the class from part I Write a procedural application TestPerson in a file called TestPerson.java This tester program should have a main method in which you should: 1. Prompt for and then read user input from the keyboard to create two Person objects (instantiation in step 2, below), e.g., java.util.Scanner rd = new java.util.Scanner(System.in); System.out.println("Please enter the full name of person 1:"); String name1 = rd.next(); System.out.println("Please enter the age of person 1:"); int age1 = rd.nextInt(); System.out.println("Please enter the gender of person 1 (F/M/T:"); char gender1 = (rd.next().charAt(0)); You will need another set of the statements like the ones given above to create the second person. 2. Use the keyword "new" and call the 3-parameter constructor written in the Person class to instantiate each Person instance. 3. call the toString method of each object within a System.out.println statement to print all data fields for each object, and 4. print the total number of objects created by accessing the static counter in the Person class, Person.counter. //////////////////////////////////////////////////////////////////////////// The output from the tester program should look like this (with your own choices for names, etc.): Person 1: Harvey Jones 14 M // these 2 lines are from Person 2: Wanda Schultz 36 F // calls to toString() Total people = 2 // This is a separate print statement. Show your files to your professor or a coach and get checked off when you are finished and have tested your programs. Don't forget to log out.