package student;
import java.util.HashMap;
import java.util.Map;
public class StudentDatabase {
private Map<Integer, Student> students = new HashMap<>();
private int nextId = 1;
public void addStudent(Student student) {
student.setId(nextId);
students.put(nextId, student);
nextId++;
}
public Student getStudent(int i) {
return students.get(i);
}
public void updateStudent(Student retrievedStudent) {
students.put(retrievedStudent.getId(), retrievedStudent);
}
public void listStudents() {
students.values().forEach(x -> {
System.out.println(x.toString());
});
}
}