- /**
- * ClassroomExample
creates a simulated classroom with two people objects in it.
- *
- * @author TK Rogers
- * @version 09-08-06
- */
- public class
ClassroomExample
- {
-
public static void main ( )
- {
-
int years = 16;
-
-
// The 2 lines below create instances of the People
class
-
People bob = new
People ( );
-
People martha = new People
(150, years, 4.0);
-
-
// The bob instance is calling the set_iq method of the
People class.
-
bob.set_iq ((int)(Math.random ( )*200));
// Sets bob's IQ to an integer between 0 and 199
-
-
System.out.println (" name IQ age
GPA");
-
System.out.println (" Bob " + bob.get_iq ( ) + "
" + bob.get_age ( ) + " " + bob.get_gpa ( ));
-
System.out.println (" Martha " + martha.get_iq ( ) + " " + martha.get_age ( )
+ " " + martha.get_gpa ( ));
-
-
// This line of code runs the static addPeople method.
-
People.addPeople (2);
-
System.out.println (" Number of people in classroom = " +
People.numberOfPeopleInClass);
- }
- }