001         package com.croftsoft.apps.infant;
002         
003         import java.util.*;
004         
005         /*********************************************************************
006         * Data recorded for analysis.
007         * 
008         * @version
009         *   $Id: InfantData.java,v 1.4 2007/12/01 00:51:07 croft Exp $
010         * @since
011         *   2006-03-05
012         * @author
013         *   <a href="https://www.croftsoft.com/">David Wallace Croft</a>
014         *********************************************************************/
015    
016         public final class  InfantData
017         //////////////////////////////////////////////////////////////////////
018         //////////////////////////////////////////////////////////////////////
019         {
020           
021         private static final class  Record
022         {
023           long
024             cycle,
025             stimulus;
026           
027           double
028             contemplation,
029             duration;
030           
031           public  Record (
032             final long    cycle,
033             final long    stimulus,
034             final double  duration,
035             final double  contemplation )
036           {
037             this.cycle         = cycle;
038             
039             this.stimulus      = stimulus;
040             
041             this.duration      = duration;
042             
043             this.contemplation = contemplation;
044           }
045         }
046           
047         private final List<Record>  recordList;
048         
049         //////////////////////////////////////////////////////////////////////
050         //////////////////////////////////////////////////////////////////////
051         
052         public  InfantData ( )
053         //////////////////////////////////////////////////////////////////////
054         {
055           recordList = new ArrayList<Record> ( );
056         }
057         
058         //////////////////////////////////////////////////////////////////////
059         //////////////////////////////////////////////////////////////////////
060         
061         public void  record (
062           final long    cycle,
063           final long    stimulus,
064           final double  duration,
065           final double  contemplation )
066         //////////////////////////////////////////////////////////////////////
067         {
068           recordList.add (
069             new Record ( cycle, stimulus, duration, contemplation ) );           
070         }
071         
072         public String  report ( )
073         //////////////////////////////////////////////////////////////////////
074         {
075           final StringBuffer  stringBuffer = new StringBuffer ( );
076           
077           for ( final Record  record : recordList )
078           {
079             stringBuffer.append (
080               String.format ( "%1$d %2$d %3$1.3f %4$1.3f%n",
081                 new Long   ( record.cycle         ),
082                 new Long   ( record.stimulus      ),
083                 new Double ( record.duration      ),
084                 new Double ( record.contemplation ) ) );
085           }
086           
087           return stringBuffer.toString ( );
088         }
089         
090         //////////////////////////////////////////////////////////////////////
091         //////////////////////////////////////////////////////////////////////
092         }