Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: i do not know how to solve this issue

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default i do not know how to solve this issue

    public class CcaExercise
    {
    	private String academicYear;
    	private String semester;
    	private Student [] appList;
    	private Cca [] ccaList;
     
    	public CcaExercise (String academicYear, String semester, Student [] appList, Cca [] ccaList)
    	{
    		this.academicYear=academicYear;
    		this.semester=semester;
    		this.appList=appList;
    		this.ccaList=ccaList;
    	}
     
    	public void addStudentToExercise(Student s)
    	{
    		for(int i=0; i< appList.length;i++)
    		{
    			if(appList[i]==null)
    			{
    				appList[i]=s;
    				break;
    			}
    		}
    	}
    	public Student getStudentInExercise(String nric)
    	{
    		for(int i=0;i<appList.length;i++)
    		{
    			if(appList[i] !=null&&
    				appList[i].getNric().equals(nric))
    				{
    					return appList[i];
    				}
    		}
    		return null;
    	}
    	public void displayAllStudents()
    	{
    		for(int i=0; i<appList.length;i++)
    		{
    			if(appList[i] !=null)
    			{
    				System.out.println(appList[i].toString());
    			}
    			}
     
    		}
    		public void addCca(Cca c)
    		{
    			for(int i=0;i<ccaList.length;i++)
    			{
    				if(ccaList[i]==null)
    				{
    					ccaList[i]=c;
    					break;
    				}
    			}
    		}
    		public boolean removeCca(String ccaID)
    		{
    			boolean result=false;
    			for(int i=0;i<ccaList.length;i++)
    			{	
    				if(ccaList[i].getCcaID().equals(ccaID))
    				{
    					ccaList[i]=null;
    					result=true;
    					break;
    				}
    			}
    			return result;
    		}
    		public void displayAllCcas()
    		{
    			for(int i=0;i<ccaList.length;i++)
    			{
    				if(ccaList[i]!=null)
    				{
    					System.out.println(ccaList[i].toString());
    				}
    			}
    		}
    		public Cca findMostVacancy()
    		{
    			//search for cca with largest number of vacancy
    			int largest=0;
    			Cca result=null;
    			for(int i=0;i<ccaList.length;i++)
    			{
    				if(ccaList[i]!=null&&
    					ccaList[i].getNumOfVacancy()>largest)
    					{
    						//update largest value
    						largest=ccaList[i].getNumOfVacancy();
    						//save the object having largest value
    						result=ccaList[i];
    					}
    		}
    		return result;	
    }
    public Cca findLeastVacancy()
    {
    	//search for CCA with smallest number of vacancy
    	int smallest=101;
    	Cca result=null;
    	for(int i=0;i<ccaList.length;i++)
    	{
    		if(ccaList[i]!=null&&
    			ccaList[i].getNumOfVacancy()<smallest)
    			{
    				//update the smallest value
    				smallest=ccaList[i].getNumOfVacancy();
    				//save the object having smallest value
    				result=ccaList[i];
    			}
    		}
    		return result;
    }
    public void displayAllStudentsAllCca()
    {
    	//print all students in all ccas
    	for(int i=0;i<ccaList.length; i++)
    	{
    		if(ccaList[i]!=null)
    		{
    			ccaList[i].displayStudentList();
    		}
    	}
    }
    public int processApplications()
    {
    	int success=0;
    	for(int i=0;i<appList.length;i++)
    	{
    		//for each student
    		//search for CCA that student apply to
    		for(int j=0;j<ccaList.length;j++)
    		{
    			if(ccaList[j]!=null&&
    				ccaList[j].getCcaID().equals(appList[i].getCcaRequest())&&
    				ccaList[j].getNumOfVacancy()>0&&
    				appList[i].getCgpa()>ccaList[j].getMinEntryCgpa())
    				{
    					// add student to ccaLists studentList array
    					ccaList[j].updateStudentList(appList[i]);
    					//remove applicant from applist
    					appList[i]=null;
    					ccaList[j].setNumOfVacancy(ccaList[j].getNumOfVacancy()-1);
    					success++;
    				}
     
    		}
     
    	}
    	return success;
     
     
    }
    public void displayNumberPerCca()
    {
    	for(int i=0;i<ccaList.length;i++)
    	{
    		if(ccaList[i]!=null)
    		{
    			System.out.println(100-ccaList[i].getNumOfVacancy());
    		}
       }
     }
    }


    The problem are

    CcaExercise.java:133: displayStudentList(java.lang.String) in Cca cannot be applied to ()
    ccaList[i].displayStudentList();
    ^
    CcaExercise.java:152: updateStudentList(java.lang.String) in Cca cannot be applied to (Student)
    ccaList[j].updateStudentList(appList[i]);
    ^
    2 errors


    as i see the fault is at another class code called Cca

    this is the Cca Class code

    public class Cca{
     
     
    	private String ccaID;
    	private String name;
    	private int numOfVacancy;
    	private Student[]studentList;
    	private double minEntryCgpa;
     
    	public Cca(String ccaID,String name,int numOfVacancy,Student[]studentList,double minEntryCgpa){
     
    		this.ccaID = ccaID;
    		this.name = name;
    		this.numOfVacancy = numOfVacancy;
    		this.studentList = studentList;
    		this.minEntryCgpa = minEntryCgpa;
     
    	}
    	public String getCcaID()
    	{
     
    		return ccaID;
    	}
     
    	public String getName()
    	{
     
    		return name;
    	}
     
    	public int getNumOfVacancy()
    	{
     
    		return numOfVacancy;
    	}
     
    	public void setNumOfVacancy(int numOfVacancy)
    	{
     
    		this.numOfVacancy = numOfVacancy;
    	}
     
    		public double getMinEntryCgpa()
    	{
     
    		return minEntryCgpa;
    	}
     
    		public void setMinEntryCgpa(double minEntryCgpa)
    	{
     
    		this.minEntryCgpa = minEntryCgpa;
    	}
     
    	public Student updateStudentList(String nric)
    	{
     
    		for(int count =0;count<studentList.length;count++)
    		{
    			if(studentList[count] != null &&
    				studentList[count].getNric().equals(nric))
    				{
     
    				return studentList[count];
    			}
    		}
    		return null;
    	}
     
    	public Student displayStudentList(String name)
    	{
     
    		for(int count =0;count<studentList.length;count++)
    		{
    			if(studentList[count] != null &&
    				studentList[count].getName().equals(name))
    				{	
    				return studentList[count];
    			}
    		}
    		return null;
    	}
     
    		public String toString()
    		{
    		String info = "ccaID:" +ccaID +"\nName:" +name +"\nNumOfVacancy:" +numOfVacancy;
    		return info;
    	}
     
    }

    Can anyone help me solve it thz alot
    Last edited by helloworld922; January 15th, 2010 at 02:43 AM. Reason: Please use [code] tags!


  2. #2
    Junior Member
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: i do not know how to solve this issue

    i know my code very messy i apologize

  3. #3
    Junior Member james's Avatar
    Join Date
    Jan 2010
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Angry Re: i do not know how to solve this issue

    why don't you analyzes it again

Similar Threads

  1. url pattern issue - please help me...
    By bharathik in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: November 9th, 2009, 04:28 AM
  2. Repeating program issue
    By Bill_H in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 24th, 2009, 10:58 AM
  3. help me out with the following code to solve the error
    By romilc in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 11th, 2009, 03:45 AM
  4. Replies: 3
    Last Post: June 14th, 2009, 09:31 PM
  5. Issues with Tomcat 6.0
    By sanyog24681 in forum Java Servlet
    Replies: 0
    Last Post: October 21st, 2008, 07:55 AM