Created
May 3, 2014 12:11
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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