I have a class University that contains (among other things) a list of semesters and a method:
public Map<String,Integer> gradesMap(Student s,Semester s)
that should return a map of grades for a given student in a given semester.
Classes Semester and Course look something like this:
public class Semester{
...
private List<Course> courses;
public List<Courses> getCourses(){return courses;}
...
}
public class Course{
...
String courseName;
private Map<Student,Integer> courseGrades;
public Map<Student,Integer> getCourseGrades(){return courseGrades;}
public String getCourseName(){return courseName;}
...
}
I tried writing something like:
Map<String,Integer> grades=semester.getCourses().stream().
forEach(c->c.getCourseGrades()).collect(Collectors.toMap(key,value));
but I'm not sure how to fetch the key and value for my map. Any suggestions would be appreciated.
Edit: Output map should contain a Course name and a grade.