예제 #1
0
 public Student getStudent(int id) {
   Student student = null;
   for (Student s : this.students) {
     if (s.getId() == id) {
       student = s;
     }
   }
   return student;
 }
예제 #2
0
 public Student modifyNationality(int id, String nationality) {
   Student student = null;
   for (Student s : this.students) {
     if (s.getId() == id) {
       s.setNationality(nationality);
       student = s;
     }
   }
   return student;
 }
예제 #3
0
 public Student modifyAge(int id, int age) {
   Student student = null;
   for (Student s : this.students) {
     if (s.getId() == id) {
       s.setAge(age);
       student = s;
     }
   }
   return student;
 }
예제 #4
0
 public Student addNewStudent(Student student) {
   for (Student s : this.students) {
     if (s.getFirstName().equals(student.getFirstName())
         && s.getLastName().equals(student.getLastName())
         && s.getId() == student.getId()) {
       return null;
     }
   }
   this.students.add(student);
   return student;
 }