All pastes #396852 Raw Edit

Someone

public java v1 · immutable
·published 2007-03-16 01:58 UTC
rendered paste body
/*-------------Java Project - StudentName: Irfan Ayub-------------*/import java.util.*;  // provides the ArrayList classpublic class ModuleDataStore{  // begin class ModuleDatStoreaArrayList data; // declares an ArrayList object called 'data'/* The constructor method. Creates the ArrayList object 'data' */public ModuleDataStore() { // begin constructor method */data = new ArrayList();}  // end constructor method *//* Adds a new student data entry to the ArrayList 'data' */public void addNewStudentRecord(String aNumber, String aName, int mark1, int mark2){ // begin addNewStudentEntry method */	Student aStudent;	aStudent =new Student(aNumber,aName,mark1,mark2);	data.add(aStudent);} // end addNewStudentRecord method *//* Returns, as a String, the number, name and the two test marks of every student currently stored in the ArrayList 'data'. */public String toString(){ // begin toString()  method	String details="";		//creates an empty string    for(int i=0;i<data.size();i++) 	//loop through the arraylist	{		Student aStudent=(Student) 	//get the student		data.get(i);		//get the student at current i position in array list		details+=aStudent.toString()+"\n"+"\n"+"\n";	//add its details to the string	}		return details;		//return the string}  // end toString() method	/* returns the mark of the student with the specified name */public int getStudentRecord(String aNumber){ // begin methodfor(int i =0; i < data.size(); i++) //loop through all of the students in the list	{	Student aStudent = (Student) data.get(i); //get the student in the i'th position	if(aStudent.getPNumber().equals(aNumber)) //is it the student being searched for?		{		return aStudent.getTest1(); //if so then return it's test 1 mark		}	} // end for	return -1;  // This will be done if the student is not found to inform the program}  // end getStudentRecord() methodpublic String getStudentGrade(String aNumber){ // begin getStudentGrade method//You will need to loop through the ArrayList dataStore to retrieve the specified Student object    for(int i=0;i<data.size();i++) //loop through all of the students in the list    {        Student aStudent = (Student) data.get(i); //get the student in the i'th position        if (aStudent.getPNumber().equals(aNumber)) //is it the student being searched for? 	    {  	        return aStudent.getGrade(); //if so then return it's grade        }    }	return -1;  // This will be done if the cat is not found to inform the program}} // end class ModuleDataStore