Exercises the methods i@see SimplePerson
@author
@version
import java.util.Scanner;
public class SimplePersonDriver{
Request and sets the color for a person (using a separate Scanner object)
public static void getPersonData( SimplePerson pep ){
Scanner stdinScanner = new Scanner( System.in );
String color;
System.out.println( "Please enter " + pep.getName() + "'s favorite color: ");
color = stdinScanner.next();
pep.setColor( color );
}
Creates multiple SimplePerson objects
public static void main( String[] args ){
Scanner stdinScanner = new Scanner( System.in );
int numPersons = 0;
SimplePerson person;
String name;
System.out.println("How many people do you have to enter: ");
numPersons = stdinScanner.nextInt();
for( int personI = 0; personI < numPersons; ++personI ){
System.out.println( "Please enter a name: ");
name = stdinScanner.next();
person = new SimplePerson( name );
System.out.println(person.getName());
getPersonData( person );
System.out.println( person.toString() );
}
}
}