// ClassRoll.java
public class ClassRoll {
private HashMap students = new HashMap();
private void addStudent ( Student stud ) {
students.put(stud.getName(), stud) ;
}
private void removeStudent( Student stud ) {
students.remove( stud.getName() ) ;
}
public boolean changeRoll( int code, Student stud ) {
switch( code ) {
case 1: addStudent( stud );
return true ;
case 2: removeStudent( stud );
return true ;
default : return false ;
}
}
public boolean isInRoll(Student stud) {
return students.containsKey(stud.getName());
}
}
// Student.java
public class Student {
private String name;
public Student(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
U have to edit code so application could work safe with any number of streams. Choose an optimal set of changes, which leads to success.
Login in to like
Login in to comment