- /**
- * Defines the data
associated with people.
- *
- * @author TK Rogers
- * @version 9/28/2010
- */
- public class
People
- {
- //
fields: contain separate values for each instance of the class.
-
private int
iq,
-
age;
-
private double gpa;
-
- //
static or class variables: Stores a single value regardless of how
- // many
instances are created.
-
public static int numberOfPeopleInClass;
-
-
- //
constructors: establish the initial values of fields.
-
public People ( ) {
-
//This constructor sets default values
- iq
= 85;
- age
= 15;
- }
-
-
public People (int i,
int a, double g) {
-
// This constructor sets unique values
- iq
= i;
- age
= a;
- gpa
= g;
- }
-
- //
Static methods can only alter static variables.
-
public static void addPeople (int n) {
-
numberOfPeopleInClass += n;
- }
-
- //
instance methods can alter fields.
-
public int get_iq ( ) {
-
return iq;
- }
-
-
public void set_iq (int i) {
- iq
= i;
- }
-
-
public int get_age ( ) {
-
return age;
- }
-
-
public void set_age (int a) {
- age
= a;
- }
-
-
public double get_gpa ( ) {
-
return gpa;
- }
-
-
public void set_gpa (double g) {
- gpa
= g;
- }
- }