package class7_2_PassingTheBuckAndReadingFiles_StudentRecords_start;// Dr. Yoder. MSOE. 26 April 2017 import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Student { private Scanner scanner = new Scanner(System.in); private String name; private String major; private List coursesCompleted = new ArrayList<>(); /** * @param filename -- File to read student info from. Currently ignored. */ public Student(String filename) { readHeader(); readBody(); } /** * Read student's full name and a description of their major, * One on each line so they can include spaces */ private void readHeader() { name = scanner.nextLine(); major = scanner.nextLine(); } /** * Read classes the student has taken. * One class on each line. */ private void readBody() { String line = scanner.nextLine(); while(!line.equals("end")) { coursesCompleted.add(line); line = scanner.nextLine(); } } /** * @return The student's full name */ public String getName() { return name; } /** * @return A description of the student's major */ public String getMajor() { return major; } public void printCourses() { System.out.println("Courses for "+name+": "); for(String course: coursesCompleted) { System.out.println(course); } } }