Skip to content

Instantly share code, notes, and snippets.

@DouglasAllen
Created May 3, 2014 12:11
Show Gist options
  • Save DouglasAllen/01571ce5a043ae32cd87 to your computer and use it in GitHub Desktop.
Save DouglasAllen/01571ce5a043ae32cd87 to your computer and use it in GitHub Desktop.
Introduction to OOP with Java (5th Ed), McGraw-Hill Wu/Otani Chapter 13 Sample Program: Illustrate a sample processing of Student and its subclasses
package Chapter13;
/*
Introduction to OOP with Java (5th Ed), McGraw-Hill
Wu/Otani
Chapter 13 Sample Program: Illustrate a sample processing of
Student and its subclasses
File: Ch13TestStudents.java
*/
public class Ch13TestStudents {
public static void main(String[] args) {
Student[] roster = new Student[5];
roster[0] = new GraduateStudent();
roster[1] = new UndergraduateStudent();
roster[2] = new UndergraduateStudent();
roster[3] = new GraduateStudent();
roster[4] = new GraduateStudent();
for (int i = 0; i < roster.length; i++) {
roster[i].setTestScore(1, 70);
roster[i].setTestScore(2, 70);
roster[i].setTestScore(3, 70);
}
for (int i = 0; i < roster.length; i++) {
roster[i].computeCourseGrade();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment