i do not know how to solve this issue
Code :
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
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
Re: i do not know how to solve this issue
i know my code very messy i apologize:o
Re: i do not know how to solve this issue
why don't you analyzes it again
^#(^^#(^