for the grade

profileali071907
ArrayExample.zip

ArrayExample/build.xml

Builds, tests, and runs the project ArrayExample.

ArrayExample/input/studentList.txt

Boucher,Thomas,66,3.8 Boucher,Daniel,64,3.9 Boucher,Michael,53,4.0 Boucher,Jeff,60,3.9 Oberlin,Kelli,59,3.5 Lekovich,Erin,58,3.4 Hunsucker,Courtney,57,3.6 Cooke,Shannon,56,2.5 Boucher,Gregory,54,3.7

ArrayExample/manifest.mf

Manifest-Version: 1.0 X-COMMENT: Main-Class will be added automatically by build

ArrayExample/nbproject/build-impl.xml

Must set src.dir Must set test.src.dir Must set build.dir Must set dist.dir Must set build.classes.dir Must set dist.javadoc.dir Must set build.test.classes.dir Must set build.test.results.dir Must set build.classes.excludes Must set dist.jar Must set javac.includes No tests executed. Must set JVM to use for profiling in profiler.info.jvm Must set profiler agent JVM arguments in profiler.info.jvmargs.agent Must select some files in the IDE or set javac.includes To run this application from the command line without Ant, try: java -jar "${dist.jar.resolved}" Must select one file in the IDE or set run.class Must select one file in the IDE or set run.class Must select one file in the IDE or set debug.class Must select one file in the IDE or set debug.class Must set fix.includes This target only works when run from inside the NetBeans IDE. Must select one file in the IDE or set profile.class This target only works when run from inside the NetBeans IDE. This target only works when run from inside the NetBeans IDE. This target only works when run from inside the NetBeans IDE. Must select one file in the IDE or set run.class Must select some files in the IDE or set test.includes Must select one file in the IDE or set run.class Must select one file in the IDE or set applet.url Must select some files in the IDE or set javac.includes Some tests failed; see details above. Must select some files in the IDE or set test.includes Some tests failed; see details above. Must select some files in the IDE or set test.class Must select some method in the IDE or set test.method Some tests failed; see details above. Must select one file in the IDE or set test.class Must select one file in the IDE or set test.class Must select some method in the IDE or set test.method Must select one file in the IDE or set applet.url Must select one file in the IDE or set applet.url

ArrayExample/nbproject/genfiles.properties

build.xml.data.CRC32=b4e90873 build.xml.script.CRC32=f3dcc917 [email protected] # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=b4e90873 nbproject/build-impl.xml.script.CRC32=b586ee27 nbproject/[email protected]

ArrayExample/nbproject/project.properties

annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processor.options= annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output build.classes.dir=${build.dir}/classes build.classes.excludes=**/*.java,**/*.form # This directory is removed when the project is cleaned: build.dir=build build.generated.dir=${build.dir}/generated build.generated.sources.dir=${build.dir}/generated-sources # Only compile against the classpath explicitly listed here: build.sysclasspath=ignore build.test.classes.dir=${build.dir}/test/classes build.test.results.dir=${build.dir}/test/results # Uncomment to specify the preferred debugger connection transport: #debug.transport=dt_socket debug.classpath=\ ${run.classpath} debug.test.classpath=\ ${run.test.classpath} # Files in build.classes.dir which should be excluded from distribution jar dist.archive.excludes= # This directory is removed when the project is cleaned: dist.dir=dist dist.jar=${dist.dir}/ArrayExample.jar dist.javadoc.dir=${dist.dir}/javadoc excludes= includes=** jar.compress=false javac.classpath= # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false javac.external.vm=true javac.processorpath=\ ${javac.classpath} javac.source=1.8 javac.target=1.8 javac.test.classpath=\ ${javac.classpath}:\ ${build.classes.dir} javac.test.processorpath=\ ${javac.test.classpath} javadoc.additionalparam= javadoc.author=false javadoc.encoding=${source.encoding} javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false javadoc.private=false javadoc.splitindex=true javadoc.use=true javadoc.version=false javadoc.windowtitle= main.class=arrayexample.ArrayExample manifest.file=manifest.mf meta.inf.dir=${src.dir}/META-INF mkdist.disabled=false platform.active=default_platform run.classpath=\ ${javac.classpath}:\ ${build.classes.dir} # Space-separated list of JVM arguments used when running the project. # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. # To set system properties for unit tests define test-sys-prop.name=value: run.jvmargs= run.test.classpath=\ ${javac.test.classpath}:\ ${build.test.classes.dir} source.encoding=UTF-8 src.dir=src test.src.dir=test

ArrayExample/nbproject/project.xml

org.netbeans.modules.java.j2seproject ArrayExample

ArrayExample/src/arrayexample/ArrayExample.java

ArrayExample/src/arrayexample/ArrayExample.java

/**
 *
 *   Course: CS310 Data Structures.
 *
 *  Program Description: An program example of working with 
 *  an array data structure.  This program implements an
 * array of student objects.  It reads a list of students
 * from a file.  Creates a Student object for each student
 * and adds that student to an array.
 * 
 * Note: This list of students file is a CSV formatted file.
 *   
 *
 */

// Any required import files are placed after this line.

package  arrayexample ;

import  java . util . Scanner ;
import  java . io . * ;


/**
 *
 *  @author  Thomas W. Boucher
 *  @version  1, Java Example Week 2
 *
 */
public   class   ArrayExample   {

     // Global Constants declared after this line
    
     // Static variable
     static   StudentArrayImpl  studentArray  =   new   StudentArrayImpl ();

     /**
     *  @param  args the command line arguments
     */
     public   static   void  main ( String []  args )   {
         // Local Constants declared after this line
        

         // Local method variables declared here.
        
        programDescription ();

         // Code to read a file and file an array
        processFile ();


         // Display Student list
        displayStudentList ();


     }

     /**
     * 
     * Method: programDescription
     *  Provides a textual description of the operation
     * of the program to the user when the program first
     * starts.
     * Parameters: None
     * Return Value: None
     * 
     */
     public   static   void  programDescription ()   {
         System . out . print ( "This program implements an" );
         System . out . println ( " example of a program" );
         System . out . print ( "which adheres to the CS310 " );
         System . out . println ( "Coding Standards document." );
         System . out . println ();
     }
    
     public   static   void  processFile ()   {

         final   String  INPUT_FILENAME  =   "input/studentList.txt" ;

         // Code to open a file for reading
         File  inFile  =   null ;    // Just create some storage for a reference to a File object
         Scanner  fileData  =   null ;    // Just create some storage for a reference to a Scanner object
         String  inFileName  =  INPUT_FILENAME ;    // An input file name.
        
         // If we were to get the file name from the user the following
         // commented out statement could be used.
         //Scanner userInput = new  Scanner(System.in);  // access keyboard
        
         // We assume initially that file was not opened properly
         boolean  inFileOpen  =   false ;    // an indicator that file was opened properly
         do   {
       
             // If we were getting the file name from the user
             // the following commented out statements could be used.
             //System.out.print("Enter a data input file name: ");
             //inFileName = userInput.next();  // Get file name from user
            
             try   {
                inFile  =   new   File ( inFileName );    // Open file
                fileData  =   new   Scanner ( inFile );   // attach to input methods
                inFileOpen  =   true ;
             }   catch ( FileNotFoundException  fnfe )   {
                 System . err . println ( "Failed to open file '"  
                     +  fnfe . getMessage ()   +   "'" );
                 System . exit ( 1 );
             }   catch   ( Exception  e )   {
                e . printStackTrace ();
             }    
         }   while   ( ! inFileOpen );
        
         // We have a valid open of a file for input
         // Now process the file data
        
         // variable for creation of student object
         Student  aStudent  =   null ;
        
         while   ( fileData . hasNextLine ())   {
             String  studentLine  =  fileData . nextLine ();
             // Insure that the line has data in it
             if   (   ! studentLine . isEmpty ())   {
                 String   []  studentData  =  studentLine . split ( "," );
                 String  lastName  =  studentData [ 0 ];
                 String  firstName  =  studentData [ 1 ];
                 int  age  =   Integer . parseInt ( studentData [ 2 ]);
                 double  gpa  =   Double . parseDouble ( studentData [ 3 ]);
                
                 // Construct a student object
                aStudent  =   new   Student ( firstName ,  lastName ,  age ,  gpa );
                 // add the student object into the array
                studentArray . add ( aStudent );     
             }
         }
        
        fileData . close ();
     }

     public   static   void  displayStudentList ()   {
         int  studentCount  =  studentArray . getNumStudents ();
         for   ( int  index  =   0 ;  index  <  studentCount ;  index ++ )   {
             System . out . println ( studentArray . getStudents ()[ index ]. toString ());
         }
     }
}

ArrayExample/src/arrayexample/Student.java

ArrayExample/src/arrayexample/Student.java


package  arrayexample ;

import  java . util . Objects ;

/**
 * 
 * Student -- description of 'Student'.
 *  The student object models the name and age of a student.
 *  
 *
 *  @author  Thomas Boucher
 *  @version  1.0, Java Week 2 Example Object
 *
 */
public   class   Student   {
     // Any global constants are declared below
     final   static   double  PERCENT_CONVERT  =   0.01 ;
    
     // Instance variables or private members are declared below
     private   String  firstName ;
     private   String  lastName ;
     private   int      age ;
     private   double  gpa ;

     /**
     * Parameterized Constructor for Student Class
     * 
     *  @param  firstName
     *  @param  lastName
     *  @param  age
     *  @param  gpa 
     */
     public   Student ( String  firstName ,   String  lastName ,   int  age ,   double  gpa )   {
         this . firstName  =  firstName ;
         this . lastName  =  lastName ;
         this . age  =  age ;
         this . gpa  =  gpa ;
     }

     /**
     * Getter of student first name
     * 
     *  @return  firstName
     */
     public   String  getFirstName ()   {
         return  firstName ;
     }

     /**
     * Setter of student first name
     * 
     *  @param  firstName 
     */
     public   void  setFirstName ( String  firstName )   {
         this . firstName  =  firstName ;
     }

     /**
     * Getter of student last name
     * 
     *  @return  lastName
     */
     public   String  getLastName ()   {
         return  lastName ;
     }

     /**
     * Setter of student last name
     * 
     *  @param  lastName 
     */
     public   void  setLastName ( String  lastName )   {
         this . lastName  =  lastName ;
     }

     /**
     * Getter of student age
     * 
     *  @return  age
     */
     public   int  getAge ()   {
         return  age ;
     }

     /**
     * Setter of student age
     * 
     *  @param  age 
     */
     public   void  setAge ( int  age )   {
         this . age  =  age ;
     }

     /**
     * Getter of student GPA
     * 
     *  @return  
     */
     public   double  getGpa ()   {
         return  gpa ;
     }

     /**
     * Setter of student GPA
     * 
     *  @param  gpa 
     */
     public   void  setGpa ( double  gpa )   {
         this . gpa  =  gpa ;
     }

    @ Override
     public   String  toString ()   {
         return   "Student{"   +   "firstName="   +  firstName  +   ", lastName="   +  lastName  +   ", age="   +  age  +   ", gpa="   +  gpa  +   '}' ;
     }

    @ Override
     public   int  hashCode ()   {
         int  hash  =   7 ;
         return  hash ;
     }

    @ Override
     public   boolean  equals ( Object  obj )   {
         if   ( this   ==  obj )   {
             return   true ;
         }
         if   ( obj  ==   null )   {
             return   false ;
         }
         if   ( getClass ()   !=  obj . getClass ())   {
             return   false ;
         }
         final   Student  other  =   ( Student )  obj ;
         if   ( this . age  !=  other . age )   {
             return   false ;
         }
         if   ( ! Objects . equals ( this . firstName ,  other . firstName ))   {
             return   false ;
         }
         if   ( ! Objects . equals ( this . lastName ,  other . lastName ))   {
             return   false ;
         }
         return   true ;
     }

        
}    // end of class Student

ArrayExample/src/arrayexample/StudentArrayImpl.java

ArrayExample/src/arrayexample/StudentArrayImpl.java

/**
 * 
 * StudentArrayImpl -- description of 'StudentArrayImpl'
 *  Complete description of what object is being modeled
 *  and how the class will be used.
 *
 *  @author  Thomas Boucher
 *  @version  1.0, Java Week 2 Example
 *
 */

package  arrayexample ;

public   class   StudentArrayImpl   {
     // Any global constants are declared below
     final   static   int  MAX_STUDENTS  =   50 ;
    
     // Instance variables or private members are declared below
     private   Student   []  studentArray  =   new   Student [ MAX_STUDENTS ];
     private   int  numStudents ;

     public   Student []  getStudents ()   {
         return  studentArray ;
     }

     public   int  getNumStudents ()   {
         return  numStudents ;
     }

     public   void  add ( Student  aStud )   {
         // Add a new student to next free array reference
         if   ( numStudents  <  MAX_STUDENTS )   {
            studentArray [ numStudents ]   =  aStud ;
            numStudents ++ ;
         }
     }
    
    @ Override
     public   String  toString ()   {
         return   "StudentArrayImpl{"   +   "students="   +  studentArray  +   '}' ;
     }
    
        
}    // end of class StudentArrayImpl