Hi i have made a student and cohrt collection class program
The compiler give me error: illegal start of expression line 46
The cohort class file:
import java.util.*;
public class Cohort {
private static int groupSize = 15;
private HashSet aCohort;
public Cohort()
{
aCohort = new HashSet();
}
public String add(Student aStudent)
{
if (aCohort.add(aStudent))
if (aCohort.add(aStudent))
{
return "success";
}
return "failure";
}
public String remove(String aSudent)
{
Iterator it = aCohort.iterator();
while (it.hasNext())
{
Student aStudent = (Student)it.next();
if (aStudent== aStudent.getName()) {
{
it.remove();
return "success";
}
}
return "failure";
}
private String update(aStudent aStudent)
{
if (remove(Student.getName()) == "success")
{
return add(aStudent);
}
return "failure";
}
public Student search(String aName)
{
Iterator it = aCohort.iterator();
while (it.hasNext())
{
Student aStudent = (Student)it.next();
if (aName == aStudent.getName())
{
return aStudent;
}
}
return null;
}
public String toString()
{
String s = new String();
Iterator it = aCohort.iterator();
while (it.hasNext())
{
Student aStudent = (Student)it.next();
s = s + aStudent.toString();
if (it.hasNext())
{
s = s + "\n";
}
}
return s;
}
public static void main(String args[])
{
Cohort aCohort = new Cohort();
Student aStudent = new Student("Nathan","Leicester Uk");
System.out.println("Add student to Cohort: " + aCohort.add(aStudent));
System.out.println(aCohort.toString());
Student bStudent = new Student("Steve","Manchester Uk");
System.out.println("Add student to Cohort: " + aCohort.add(bStudent));
System.out.println(aCohort.toString());
Any help would be greatly appreciated