home *** CD-ROM | disk | FTP | other *** search
/ Sams Teach Yourself C in 21 Days (6th Edition) / STYC216E.ISO / mac / Examples / Day26 / Lists.java / Lists.java
Encoding:
Java Source  |  2002-05-26  |  402 b   |  25 lines  |  [TEXT/LMAN]

  1. public class ListOfNumbers {
  2.  
  3.     protected int icount;
  4.     protected double itotal;
  5.  
  6.     //Constructor.
  7.     ListOfNumbers() {
  8.           icount = 0;
  9.           itotal = 0;
  10.     }
  11.  
  12.     public void Add(double x) {
  13.           icount++;
  14.           itotal += x;
  15.     }
  16.  
  17.     public int count() {
  18.           return icount;
  19.     }
  20.  
  21.     public double total() {
  22.           return itotal;
  23.     }
  24. }
  25.