All pastes #4274 Raw Edit

eXistenZi

public java v1 · immutable
#4274 ·published 2005-01-15 22:48 UTC
rendered paste body
public static void enrollStudent(String firstname, String lastname, int grade, String phonenumber, boolean criminalrecord)  {    StudentRecord newStudentRecord = new StudentRecord(firstname, lastname, grade, phonenumber, criminalrecord);      if (initial != null)     {    StudentRecord searchResult = searchByName(firstname, lastname);	newStudentRecord.nextLink (searchResult.nextStudentRecord());	searchResult.nextLink = newStudentRecord;    } else {    	        initial = newStudentRecord;    	newStudentRecord.nextLink(null);	    }      }        //Performs a search for the name   private static StudentRecord searchByName(String firstname, String lastname)   {   boolean foundpos = false; 	StudentRecord current = initial;               while ((current.nextStudentRecord () != null) && !foundpos) //Start the search            {                                if (lastname.compareTo ((current.nextStudentRecord ()).returnlName ()) > 0) //Compare the entry and the existing                    {                                        current = current.nextStudentRecord (); //Advance to the next one                                                                                        } else {                                     foundpos = true; //or indicate the position is found                                                }                            }			return current;		                       }