Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding a Item in an Array

Status
Not open for further replies.

Johno12

Programmer
Feb 23, 2006
1
US
Hello. I created a College Member Hierarchy. The user is able to input data about Members, Employees and Students. I have 6 methods in my main class. Three to accept data about them and three to query the information. I can get everthing working execpt for the query Employee Method. When you input the Employee Data its asking for various feilds in arrays but it seems to get a null pointer error when calling back to the modify method to find the array. When you search its trying to find the ID_Number that it entered. Im still learning this stuff so i might have done something wrong. It would be great if some one could help me out. Here is the code:

Code:
	// The Modify Method
	   public void Modify(Employee ThisEmp)
	   {
		   int x;
		   super.Modify(ThisEmp);//Invokes CollegeMember.Modify
		   Salary = ThisEmp.Salary;
		   Department = ThisEmp.Department;
		   JobTitle = ThisEmp.JobTitle;

		   
		   // Modify the aggregated fields based on the
corresponding fields of ThisEmp
	
		   Personal.Modify(ThisEmp.Personal);
		   
		   for (x = 1; x <= ThisEmp.EmpHistory.length; x++)
		   {
			    if (EmpHistory[x-1] == null)
			    {
			    	EmpHistory[x-1] = new
EmpEmploymentHistory();
			    }//End-If
	
EmpHistory[x-1].Modify(ThisEmp.EmpHistory[x-1]);
		   }//End-for
		   
		   for (x = 1; x<= ThisEmp.AcadRecord.length; x++)
		   {
			   if (AcadRecord[x-1] == null)
			   {
				   AcadRecord[x-1] = new
EmpAcademicRecord();
			   }//End-if
	
AcadRecord[x-1].Modify(ThisEmp.AcadRecord[x-1]);
		   }//End-for
		   
		   for (x = 1; x<= ThisEmp.Publication.length; x++)
		   {
			   if (Publication[x-1] == null)
			   {
				   Publication[x-1] = new
EmpPublicationLog();
			   }//End-if
	
Publication[x-1].Modify(ThisEmp.Publication[x-1]);
		   }//End-for

		   ExtraCurricular.Modify(ThisEmp.ExtraCurricular);
		   
	   }//End of Modify Method
And its calling from this method
Code:
		 // The Find Employee Method
	    public static Employee FindEmployee(Employee[] ThisList,
String SearchArg)
	    {
	    	// Declatations
	    	   Employee Found = null;
	    	   Found = new Employee(Found);
	    	   int x;
	    	   
	    	// Activity
	    	   for(x = 1; x <= ThisList.length; x++)
	    	   {
	    		   if
(ThisList[x-1].ID_Number.equals(SearchArg))
	    		   {
	    			   Found.Modify(ThisList[x-1]);
	    			   break;
	    		   }//End-If
	    	   }//End of For Statement
	    	   
	    	   return Found; 
	    }//End of FindEmployeeMethod
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top