for GradeBookWriter NEED help and explaination on last part? /** * GradebookWrit
ID: 640274 • Letter: F
Question
for GradeBookWriter NEED help and explaination on last part?
/**
* GradebookWriter inherits from PrintWriter and writes the gradebook info to
* the file name passed to the ctor.
*/
public class GradebookWriter extends PrintWriter {
/**
* GradebookWriter() Call the super class ctor that takes a String.
*/
public GradebookWriter(String pFname) throws FileNotFoundException {
super(pFname);
}
/**
* writeGradebook() Writes the gradebook info to the file, which was opened
* in the ctor.
*
* PSEUDOCODE: EnhancedFor each student in pRoster.getStudentList() Do Call
* println(student) End For Call close()
*/
public void writeGradebook(Roster pRoster)
{ //NEED CODE ???????
}
}
Explanation / Answer
import java.io.FileNotFoundException;
import java.io.PrintWriter;
public class GradebookWriter extends PrintWriter {
//GradeWriter constructor
public GradebookWriter(String pFname) throws FileNotFoundException {
super(pFname);
}
//Writes the gradebook info to the file, which was opened in the ctor.
public void writeGradebook(Roster pRoster) {
for (Student student : pRoster.getStudentList()) {
println(student);
}
close();
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.