Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSE205 Object Oriented Programming and Data Structures Programming Project 3: 25 pts 1 Submission Instructions Create a folder named asuriteid p03 where asuriteid is your

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

CSE205 Object Oriented Programming and Data Structures Programming Project 3: 25 pts 1 Submission Instructions Create a folder named asuriteid p03 where asuriteid is your ASURITE user id (for example, if your ASLRITE user id is jsmith6 then your folder would be named jsmith6-p0) and copy your java source code files to this folder. Do not copy the class files or any other files. Next, compress the asuriteid-p03 folder creating a zip archive file aed asuriteid-p03.ziy (c.g., jsmith6-p0S.zip. Upload asuriteid-p0S.zip to the Blackboard Projcct 3 submission link by the projcct deadlinc Please see the Course Schedule section in the Syllabus for the deadline. Consult the Syllabus for the late and academic integrity policies. 2 Learning Objectives I. Complete all of the learning objects of the previous projects. 2. To impleent a GUI interface and respond to action events 3. To implement and use the binary search algorithm. 1. To implement and use the quick sort algorithm. 5. To implemt the java.lang. Comparable T interface 3 Background This project shall implement a program which stores grade information for students in a class and allows that grade in formation to be edited. The data shall be stored in a database file named gradebook.dat. There shall be one student record per line, where the format of a student record is: last-name first-name en1 e2 e#3 hut huu2 hu? hw4 hwS wliere: The student's last name. A contiguous string of one or more characters, with no spaces last name first-name The student's first name. A contigous string of one or more characters, with no spaces. exi, ex2, ez3 The student's scores on three exams, may be zeros. Each exam is worth 100 pts. hw1-hw5 The student's scores on five homework assignments, may be zeros. Each assignment is worth 25 pts. Here is an example gradebook. dat file: Sample gradebook. dat Simpson Lisa 100 100 100 25 25 25 25 25 Flintstone Fred 80 60 40 15 17 22 18 23 Jetson George 70 83 81 20 21 22 23 25 Explosion Nathan 7 65 43210 Muntz Nelson 60 70 50 20 15 10 5 8 Terwilliger Robert 80 90 95 23 21 19 17 23 Flanders Ned 85 95 75 12 14 17 23 16 Bouvier Selma 16 16 16 16 16 16 16 16 Spuckler Cletu 1234567 Wiggum Clancy 18 16 14 12 10 8 4 2 Skinner Seymour 78 83 99 19 23 21 24 118 3 Software Requirements 1. The GUI sha be mplemented in a class naned View. When the program starts the View frame shall appear as shown in Fig. 1 2. The View frame sha be 525 pixels wide and 225 pixels high 3. The progran shal display the progra nae in the tle bar. You may change the nane of the program to anything you wish 1. The X close button in the title bar shall be disabled, i.e., when it is clicked the program shall not exit and the View shall remain unchanged. Kevin R. Burger Computer Science & Engineering:: Arizona State University: : s19a Page 1 CSE205 Object Oriented Programming and Data Structures Programming Project 3: 25 pts Gred: Gradebook Editor Student Name: Search Homework: Exam: Clear Save Exit Figure 1: The View Frame i. The student records shall be stored in a gradebook database in a file named grmdebook. dat. 6. When the program starts, if the gradebook.dat file cannot be opened for rcading, the program shall display an crror message dialog (using the JOptionPane class) informing the user that the gradebook database could not be opened for reading and that the program will terminate. When the user clicks the OK button the program shall terminate. See SR 27 7. When the program exits, if the gradebook.dat file cannot be opened for writing, the program shall display an error message dialog (using the JOptionPane class) informing the user that the gradebook database could not be opened for writing and that clicking the dialog's OK butto will cause the program to terminate without updating the gradebook database. When the user clicks the OK button the program shall terminate. See SR 27. When the program starts, no student record shall be displayed and the text fields shall be empty. See SR l 8. 9. The last names of the students in the gradebook database shall be unique (because the last name is the key when searching the database) 10. When the program starts, it shall read the contents of the gradebook database from gradebookdat and shall sort the list of students into ascending order by last name (per the Software Design requirements, it shall sort using the quick sort sorting algorithm). The sort is performed so that the program may search the database in memory for a specific student record using the binary search algorithm. 11. If the student record for a student who's last ae is "Simpson is being displayed, this is how the Views appear, displaying the studen's full name, honework scores, and exam scores. See SR's 12 14 Gred:: Gradebook Editor Student Name son, Lisa Search Homework: 25 25 25 25 Exam: 100 100 100 Clear Save Exit Figure 2: The View Displaying a Student's Grades 12. When a student record is being edited, the full name of the student shall be displayed in the Student Name text field. 13. When a student record is being edited, the student's homework 1-5 scores shall be displayed from left to right in the Homework text ficlds. 14. When a stident record is being edited, the student's exam 1-3 scores hall be displayed from left to right in the Fram text ficlds. Kevin R. Burger Computer Science & Engineering:: Arizona State University: : s19a Page 2 CSE205 Object Oriented Programming and Data Structures Programming Project 3 25 pts 15. When the Search button is clicked, if there are values being displayed in the homework and exam fields, then those ficlds shall be clearcd, i.c., sct to cmpty, beforc the scarch begins. 16. When the user clicks the Search button and the Student Name text field is empty, an error message dialog shall be dis played, requesting that the user enter a student's last name. The Student Name and numeric text fields shall all re- main empty 17. When the user enters a name in the Student Name text field and then clicks the Search button, the gradebook data base in memory shall be searched for a student who's last name matches the name in the text field. Per the Software Desig requirements, the search function shall be implemented either using either iterative binary search or recursive binary search. 18. If the search discussed in SR 17 fails because there are no students who's last name matches the name in the Student Name text field, then an error message dialog shall be displayed informing the user that a student with that last name could not be found in the gradebook. After the user clicks OK to close the dialog, the Student Name text field shall be aud the umeric text fields shallreain empty 19. If the search discussed in SR 17 succeeds, then the lomework and Exam text fields shal be updated with the stu- dent's homework and exam scores. The Student Name text field shall continue to display the student's full name per SR 12. 20. When the user is editing the homework and/or exam scores for a student and then clicks the Save button, the student record in memory shal be updated with the new scores. 21. See SR 20. These changes shall remain stored in memory and shall not be written to the gradebook database until the program exits. 22. When no student record is being edited (the homework and exam text fields are empty) and the user clicks the Save button, nt sll happen 23. Whe tle user is editing the infornation or a stude and clicks the Clear bu without first clicking the Save button then the student record in memory shall not be updated even if the homework and/or exam text fields had been modified 24. Whenstudent nforatio is being displayed or edited, and the user clicks the lear buton, heohng shall happen. 25. When the user is editing and has modified the information for a student and then clicks the Erit button, the student record (and of the other studen records) shall be writen lo the gradebook database before the program termi natos. Scc SR 7 for how write failurcs arc handled 26. Whether the user is editing student information or not, when the Erit button is clicked, all of the student records shall be written to the gradebook database and then the program shall terminate. 27. Any error message dialogs shall be displayed centered within the View frame and display a message and one button labeled OK 4 Software Design Requirements 1. All classes shall be declared in a package named proj3. 2. The UML class diagram in UMLet format ca be found in the project archive's ur folder. The ing folder contains the class diagram in PNG format. Your program sha implemet all of the classes including methods, declaring instance and class variables, and so on) of this design. Deviation from the design may result in project score deduc- Lion Kevin R. Burger Computer Science & Engineering:: Arizona State University: : s19a Page 3 Programming Project 3 25 pts 3. Class Main. A template source code file for Main is included in the project archive. The Main class shall contain the plete the code by reading the comments and implementing the psendocode, while using the UML class diagram for CSE205 Object Oriented Programming and Data Structures main) mcthod which shall instantiate an object of the Main class and then call run) on that objcct. You shall co a asa guide Main.run shall catch the FileNotFoundErception which may get thrown by Gradebook Reader.readGradebook and shall terminate the program by displaying an error message diagram which informs the user that the gradebook data base could not be opened for reading; it shall then termiate the program. See SR 6 Maii.erit shall catch the FileNotFoundException which may be thrown by Gradebook Writer. writeGradebook) when the gradebook database cannt be opened for writing; the handler shall display an error message dialog informing the user that the gradebook database file could not be opened for writing and that the gradebook will not be updated; it shall then terminate the program. See SR 7 The parameter to Main.search0 is the last name of a student and searehsha call Roster.getSludeni) to search the Roster for a student with that last name. If the student is found, it will rcturn a Student object which scarch) shall retnrn There are five homework assignments, so Main.getVumHomemorks is a class method which shall return the constant 5. Similarly, Main.getNumEzams shall return the constant 3. The remainder of the methods in Main are accessor mutator methods for various data members 4. Class GrodebookReader. The constructor of this class creates a Scanner object which is used to read the gradebook database (the Scanner object is stored in instance variable mln so that it may be used in the various read methods) Since the file open may fail, this construtor s throw the FieNotFoundException to Maii.run) which shall catch the exception This class reads the gradebook information from the gradcbook database file grudcbook.dat when readGradebook) is called. then calls readRoster() to read each studen record from the input file and then returns the created Roster objcct The readRoster) mcthod first instantiates a Roster objcct, then uses a while loop to read student rccords from the input file. For each student record, it reads the student's last and first names from the input file, creates a Student object, passing the last name and first name to the Student constructor, and then calls readHomework) and read Exa to read the student's homework and exam scores. Then it calls Roster.addStudent) to add the Student object to the Roster. Finally, it returns the Roster object that was created, back to readGradebook), which then returns the Roster back to Main.rurf) which called readGrudebook) in the first place. Note tat after reading the Rosler but before relurning the Roster to MaiL.run), ewdGrudebook() calls Roster.sort Roster) to sort the Roster. Class Gmdebook Writer. This class writes the gradebook information to gradebook dat before the program exits. It is a subclass of java.io. PrintWriter so the GradebookWriter constructor must call the PrintWriter constructor to open the file for writing. Since the open may fail, Print Writer will return the FileNotFoundErception to Gradebook Writer) which will throw it back to Mai.erit) which wil catch and handle it The gradebook database is written when uriteGradebook is called. This is a very simple method which just iterates over the Roster, writing each Student object to the file. 6. Class Roster. The class roster is implemented as an ArrayList of Student objects. addStudent) is called from Grade bookReader.readRoster) to add a Student to the Roster's ArruyList. getStudelis caled f Mai.seareh, which is called by View.aclionPomed when the user clicks the Searc button in the Vie. getStudent calls Searcher.scarch), passing the Student's last name as the key; scarch) searches Kevin R. Burger Computer Science & Engineering:: Arizona State University: : s19a Page 4 CSE205 Object Oriented Programming and Data Structures Programming Project 3 25 pts the ArmyList for the student with matching last nme using the binary search algorithm. You shall implement cither the itcrative or recursive version of the algorithm. If a Student with matching last name is found, then get Student) returns the Student object; otherwise, it returns -1 which represents the "not found" condition. sortRoster is called from Grodebook Reader, see that class for a discussion. sortRoster) calls the class method Sorter. sort) passing the ArrayList of Students as the parameter. Upon return, the ArrayList wil have been sorted Note that Roster overrides the inherited toString)method and it returns a String representation of the Roster. The string representation is just the string representation of each Student in the ArrayList, which is formed by calling Stu dent.toString) on each Student object. Roster.toStings primarily implemented for use as a useful method to call to print out the Roster during debugging. Roster.getStudeniList() and Roster.selSludenilLisl) are accessor/mutator methods for the mStudentList instance variable 7. Class Searcher. This class sha implement one public class mcthod int search(ArraylistStudent> plist, String pKey) which searches the Roster for a student with the specified last name stored in pKey. Since the roster is sorted into ascending order by last name, you shall implement cither the iterative or recursive binary scarch algorithm. The method returns the index of the student in the list or -1 if the student is not found. Template not provided; use the UML class diagram as a guide and the binary search lecture notes 8. Class Sorter. A class which implements the quicksort algorithm. All of the method are static and sort(ArruyList plist, String pKey) which searches the Roster for a student with the specified last name stored in pKey. Since the roster is sorted into ascending order by last name, you shall implement cither the iterative or recursive binary scarch algorithm. The method returns the index of the student in the list or -1 if the student is not found. Template not provided; use the UML class diagram as a guide and the binary search lecture notes 8. Class Sorter. A class which implements the quicksort algorithm. All of the method are static and sort(ArruyList

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions

Question

Discuss Ms. Lincolns level of commitment to occupational safety.

Answered: 1 week ago