Chapter 15 Case stud Class Roster Maintenance Program 2000 McGraw-Hl‖ Introduction to Object-Oriented Programming with Java-Wu Chapter 15-1
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 15 - 1 Chapter 15 Case Study: Class Roster Maintenance Program
Chapter 15 Objectives After you have read and studied this chapter, you should be able to e Develop large programs incrementally using multiple objects from object categories controller, storage, application logic, and user interface e Develop large programs that are extensible and modifiable by applying polymorphism and inheritance effectively in program design e Document how the methods in the classes are related by using method call sequence diagrams C 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 15-2
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 15 - 2 Chapter 15 Objectives After you have read and studied this chapter, you should be able to Develop large programs incrementally using multiple objects from object categories controller, storage, application logic, and user interface. Develop large programs that are extensible and modifiable by applying polymorphism and inheritance effectively in program design. Document how the methods in the classes are related by using method call sequence diagrams
Sample Program: Computing Course Grades r Problem statement Write a class roster maintenance program that will allow the user to create a new roster Open an existing roster(can open one roster at a time) Save the current roster to a file Add and delete students from a roster Change the name of students. Edit the test scores of students. Display the name test scores, and course grade of a single studentor all students in the roster The program maintains both graduate and undergraduate students. For each student, we maintain his or her name test scores, and final course grade. The final course grade is computed by using the following formula(from Chapter 14 Type of Student Grading Scheme Undergraduate Pass if(test1+test2+test3)3>=70 Graduate Pass if(test1+test2test3)/3>=80 C 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 15-3
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 15 - 3 Sample Program: Computing Course Grades Problem Statement Write a class roster maintenance program that will allow the user to Create a new roster. Open an existing roster (can open one roster at a time). Save the current roster to a file. Add and delete students from a roster. Change the name of students. Edit the test scores of students. Display the name, test scores, and course grade of a single student or all students in the roster. The program maintains both graduate and undergraduate students. For each student, we maintain his or her name, test scores, and final course grade. The final course grade is computed by using the following formula (from Chapter 14): Type of Student Grading Scheme Undergraduate Pass if (test1+test2+test3)/3 >= 70 Graduate Pass if (test1+test2+test3)/3 >= 80
Design document-1 Design Document: GradeRoster Program Class Purpose GradeRoster Main The main class of the program The top-level control object that manages subclass of Main Window from javabook. a GradeRoster MainWindow other objects in the program. The class An object that controls a Graderoster object. The object works under the control GradeRoster Control of GradeRoster Window the object manages StudentName Dialog and Testscore Dialog objects An object responsible for displaying class GradeRosterDisplay rosters. The object works under the control of graderoster mainWindow C 2000 McGraw-Hill troduction to Object-Oriented Programming with Java--Wu Chapter 15-4
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 15 - 4 Design Document - 1 Design Document: GradeRoster Program Class Purpose GradeRosterMain The main class of the program. GradeRosterMainWindow The top-level control object that manages other objects in the program. The class is a subclass of MainWindow from javabook. GradeRosterControl An object that controls a GradeRoster object. The object works under the control of GradeRosterMainWindow. The object manages StudentNameDialog and TestScoreDialog objects. GradeRosterDisplay An object responsible for displaying class rosters. The object works under the control of GradeRosterMainWindow
Design document -2 Design Document GradeRoster Program Class Purpose An object for handling the file input and GradeRoster Storage out put operations. The obj ject works under the control of graderosterMain window An object that actually maintains the roster. GradeRoster The object works under the control of GradeRoster Control An abstract class that captures common Student behavior and data of both undergraduate and graduate students C 2000 McGraw-Hill troduction to Object-Oriented Programming with Java--Wu Chapter 15-5
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 15 - 5 Design Document - 2 Design Document: GradeRoster Program Class Purpose GradeRosterStorage An object for handling the file input and output operations. The object works under the control of GradeRosterMainWindow. GradeRoster An object that actually maintains the roster. The object works under the control of GradeRosterControl. Student An abstract class that captures common behavior and data of both undergraduate and graduate students
Design document -3 Design Document GradeRoster Program Class Purpose An object to model a graduate student GraduateStudent An object to model an undergraduate UndergraduateStudent student A javabook object to print out error MessageBox messages and messages from temporary output statements C 2000 McGraw-Hill troduction to Object-Oriented Programming with Java--Wu Chapter 15-6
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 15 - 6 Design Document - 3 Design Document: GradeRoster Program Class Purpose GraduateStudent An object to model a graduate student. UndergraduateStudent An object to model an undergraduate student. MessageBox A javabook object to print out error messages and messages from temporary output statements
Grade roster Program: Object Diagram GradeRoster Control Under Grade RosterMain Grade roster GradeRoster Grade Roster MainWindow Display Graduate Student Storage C 2000 McGraw-Hill troduction to Object-Oriented Programming with Java--Wu Chapter 15-7
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 15 - 7 Grade Roster Program: Object Diagram GradeRosterMain GraduateStudent UndergraduateStudent GradeRoster GradeRosterDisplay GradeRosterStorage GradeRosterControl GradeRosterMainWindow
Development steps 1. Start with the program skeleton. Define the gradeRoster Main and skeleton GradeRoster MainWindow classes 2. Implement the methods to create a new roster. 3. Implement the methods to add students to a roster. 4. Implement the methods to delete students from a roster. 5. Implement the methods to edit student information 6. Implement the methods to edit test scores and compute the final course grades 7. Implement the methods to display the student information of a single student or all students 8. Implement the methods to save a roster to a file and read a roster from a file 9. Finalize and look for improvements C 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 15-8
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 15 - 8 Development Steps 1. Start with the program skeleton. Define the GradeRosterMain and skeleton GradeRosterMainWindow classes. 2. Implement the methods to create a new roster. 3. Implement the methods to add students to a roster. 4. Implement the methods to delete students from a roster. 5. Implement the methods to edit student information. 6. Implement the methods to edit test scores and compute the final course grades. 7. Implement the methods to display the student information of a single student or all students. 8. Implement the methods to save a roster to a file and read a roster from a file. 9. Finalize and look for improvements
Step 1: Program Shell with Menus Objects o Do GradeRoster- Implement the full class. The m Main method creates an instance of ain Grade Window and calls its setVisible method Step 1 GradeRoster- Implement the shell of the main class that MainWindow includes menu choices and corresponding methods for processing menu choices C 2000 McGraw-Hill troduction to Object-Oriented Programming with Java--Wu Chapter 15-9
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 15 - 9 Step 1: Program Shell with Menus Step 1 Objects To Do GradeRosterMain Implement the full class. The main method creates an instance of GradeRosterMainWindowand calls its setVisible method. GradeRosterMainWindow Implement the shell of the main class that includes menu choices and corresponding methods for processing menu choices
Step 2: Create a New Roster Objects TO Do Graderoster- Implement the methods Mainwindow rOster create NewRoster etNewtitle Modify the constructor as necessary Add a Response Box called save Box as a new data membe Step 2 Define constants SAVE. NO SAVE and CANCEL Grade Roster- Implement the methods Control constructor> etCourse Title as Grade Rose newGrade roster Add Input Box as a new data member Graderoster Implement the methods getTitle C 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 15-10
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 15 - 10 Step 2: Create a New Roster Step 2 Objects To Do GradeRosterMainWindow Implement the methods newRoster createNewRoster setNewTitle Modify the constructor as necessary. Add a ResponseBox called saveBox as a new data member. Define constants SAVE, NO_SAVE, and CANCEL. GradeRosterControl Implement the methods getCourseTitle hasGradeRoster newGradeRoster Add InputBox as a new data member. GradeRoster Implement the methods getTitle