1 16 import java.util.*; 17 18 import org.apache.commons.logging.Log; 19 import org.apache.commons.logging.LogFactory; 20 21 public class Statistic { 22 private static Log log = LogFactory.getLog(Statistic.class); 23 24 private int summary; 25 private DayRecord records[]; 26 27 public Statistic(){ 29 int rows = 3; 30 records = new DayRecord[rows]; 31 32 Calendar cal = Calendar.getInstance(); 33 Random rnd = new Random(); 34 35 for (int i = 0; i < rows; i++){ 36 cal.set(2004, 5, i); 37 records[i] = new DayRecord(cal.getTime(), rnd.nextInt(5000)); 38 } 39 40 } 41 42 public DayRecord[] getRecords() { 43 return records; 44 } 45 46 public void setRecords(DayRecord[] records) { 47 this.records = records; 48 } 49 50 public int getSummary() { 51 summary = 0; 52 53 for (int i = 0; i < records.length; i++) 54 summary += records[i].getVisitors(); 55 56 return(summary); 57 } 58 59 } | Popular Tags |