|
| 1 | +package superiterable; |
| 2 | + |
| 3 | +import students.Student; |
| 4 | + |
| 5 | +import java.util.List; |
| 6 | +import java.util.Map; |
| 7 | + |
| 8 | +public class SILab { |
| 9 | + private static final SuperIterable<Student> roster = |
| 10 | + new SuperIterable<>(List.of( |
| 11 | + students.Student.of("Fred", 3.4, "Math", "Physics"), |
| 12 | + students.Student.of("Jim", 2.4, "Journalism"), |
| 13 | + Student.of("Sheila", 3.9, "Math", "Physics", "Quantum Mechanics", "Astrophysics") |
| 14 | + )); |
| 15 | + private static final Map<String, Integer> courseLevel = Map.of( |
| 16 | + "Physics", 100, |
| 17 | + "Math", 200, |
| 18 | + "Journalism", 300, |
| 19 | + "Astrophysics", 300, |
| 20 | + "Quantum Mechanics", 400 |
| 21 | + ); |
| 22 | + |
| 23 | + private static final Map<String, Integer> creditHours = Map.of( |
| 24 | + "Physics", 4, |
| 25 | + "Math", 3, |
| 26 | + "Journalism", 4, |
| 27 | + "Astrophysics", 3, |
| 28 | + "Quantum Mechanics", 2 |
| 29 | + ); |
| 30 | + |
| 31 | + public static void main(String[] args) { |
| 32 | + System.out.println("All students"); |
| 33 | + roster |
| 34 | + // Add code HERE ONLY, so as to print |
| 35 | + // "Student: <name> has gpa: <gpa>" for all students |
| 36 | + |
| 37 | + .forEach(s -> System.out.println(s)); |
| 38 | + |
| 39 | + System.out.println("gpa below 3.5"); |
| 40 | + roster |
| 41 | + // Add code HERE ONLY, so as to print |
| 42 | + // "Student: <name> has gpa: <gpa>" for all students with gpa less than 3.5 |
| 43 | + |
| 44 | + .forEach(s -> System.out.println(s)); |
| 45 | + |
| 46 | + System.out.println("Takes more than 1 course"); |
| 47 | + roster |
| 48 | + // Add code HERE ONLY, so as to print |
| 49 | + // "Student: <name> takes <count> courses" for all students taking more than 1 course |
| 50 | + |
| 51 | + .forEach(s -> System.out.println(s)); |
| 52 | + |
| 53 | + System.out.println("Studying advanced courses"); |
| 54 | + roster |
| 55 | + // Add code HERE ONLY, so as to print |
| 56 | + // "Student: <name> takes advanced courses" for all students taking a course at 300+ level |
| 57 | + |
| 58 | + .forEach(s -> System.out.println(s)); |
| 59 | + |
| 60 | + System.out.println("Course load"); |
| 61 | + roster |
| 62 | + // Add code HERE ONLY, so as to print |
| 63 | + // "Student: <name> takes <total> credit hours" for all students |
| 64 | + |
| 65 | + .forEach(s -> System.out.println(s)); |
| 66 | + |
| 67 | + } |
| 68 | +} |
0 commit comments