Person - Person.java p public class Person cfw Declare the instance variables public static int people = 0 public static int sumOfAges = 0 public

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************* // Person.java // // //******************************************************* public class Person { p // Declare the instance variables public static int people = 0; public static int sumOfAges = 0; public static int minAge = 120; public static int maxAge = 0; p private int age; private String name; p public static int avgAge(){ return sumOfAges / people; } public static int minAge(){ return minAge; } public static int maxAge(){ return maxAge; } //---------------------------------------------- // Class Constructor: set the initial values of // the instance variables // for this Person //---------------------------------------------- / public Person(String name, int age) { this.name = name; this.age = age; if( age > maxAge ) maxAge = age; if( age < minAge ) minAge = age; people++; sumOfAges += age; } } //---------------------------------------------- // getAge - returns the age of this Person //----------------------------------------------
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/15/2010 for the course CSCI 01209 taught by Professor Storm during the Fall '10 term at University of Georgia Athens.

Page1 / 3

Person - Person.java p public class Person cfw Declare the instance variables public static int people = 0 public static int sumOfAges = 0 public

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online