Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

please help me with this as my tutor fell through and I dont understand all sections these are the programs it gave me this is

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

please help me with this as my tutor fell through and I dont understand all sections

these are the programs it gave me

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

this is the main java above

image text in transcribed

image text in transcribed

image text in transcribed

this is the grade book reader above

image text in transcribed

image text in transcribed

these are the java Gradebook writer

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

the above photos are for roster

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

these are the student files

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

this is the view code that was given to me

these where all the provided documents please reach out if you need anything else

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 ez2 e13 hwi hw2 hw3 hws hws where: last-name The student's last name. A contiguous string of one or more characters, with no spaces. first-name The student's first name. A contiguous string of one or more characters, with no spaces. exl, e12, er3 The student's scores on three exams, may be zeros. Each exam is worth 100 pts. hu1-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 6 5 4 3 2 1 0 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 Cletus 1 2 3 4 5 6 7 8 Wiggum Clancy 18 16 14 12 10 8 4 2 Skinner Seymour 78 83 99 19 23 21 24 18 3 Software Requirements 1. The GUI shall be implemented in a class named View. When the program starts the view frame shall appear as shown in Fig. 1. Sample gradedoor.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 6 5 4 3 2 1 0 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 Cletus 1 2 3 4 5 6 7 8 Wiggum Clancy 18 16 14 12 10 8 4 2 Skinner Seymour 78 83 99 19 23 21 24 18 3 Software Requirements 1. The GUI shall be implemented in a class named View. When the program starts the View frame shall appear as shown in Fig. 1. 2. The View frame shall be 525 pixels wide and 225 pixels high. 3. The program shall display the program name in the title bar. You may change the name of the program to anything you wish. 4. 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. Type here to search A ^. 8:02 PM 402/11/2020 Gred Gradebook Editor Student Names Homework: Clear Figure 1: The View Frame 5. The student records shall be stored in a gradebook database in a file named gradebook dat 6. When the program starts, if the gradebook. dat file cannot be opened for reading, the program shall display an error 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 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 button 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 1. 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 gradebook.det 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 name is "Simpson' is being displayed this is how the View shall appear. displaying the student's full name, homework scores, and exam scores. See SR's 12-14 Gred Gradebook Edit Student Name Search a O cse205-p03.pdf o file://C:/Users/dow12/Documents/Spring%202020/CSE%20205/cse205 po3.pdf TIST OF STUUCnS mo ascenumg oruci wy last name per te JOTWOLE Design ICYUCILIUS, IU Duan son using we 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 name is "Simpson" is being displayed, this is how the View shall appear, displaying the student's full name, homework scores, and exam scores. See SR's 12-14. Gred :: Gradebook Editor Student Name: Simpson, Lisa Search Homework: 25 25 25 25 25 Exam: 100 100 100 ClearSave 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 displaved from left to right in the Homework text fields. 14. When a student record is being edited, the student's exam 1-3 scores shall be displayed from left to right in the Exam text fields. 15. When the Search button is clicked, if there are values being displayed in the homework and exam fields, then those fields shall be cleared, i.e., set to empty, before the search 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 Design 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 whose 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 cleared and the numeric text fields shall remain empty 19. If the search discussed in SR 17 succeeds, then the Homework and Eram text fields shall 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 shall 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, nothing shall happen 23. When the user is editing the information for a student and clicks the Clear button without first clicking the Sate button, then the student record in memory shall not be updated even if the homework and or exam text fields had been modified 24. When no student information is being displayed or edited and the user clicks the Clear button, then nothing shall he/CUsersuw1 C opy ULULULU OLULU dent's homework and exam scores. I ne student Name text neid air continue to display the student stuur 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 shall 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 click the Save button, nothing shall happen. 23. When the user is editing the information for a student and clicks the Clear button, 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. When no student information is being displayed or edited, and the user clicks the Clear button, then nothing shall happen 25. When the user is editing and has modified the information for a student and then clicks the Exit button, the student record (and all of the other student records shall be written to the gradebook database before the program termi nates. See SR 7 for how write failures are handled. 26. Whether the user is editing student information or not, when the Exit 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 dialoga 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 proj 2. The UML class diagram in UMLet format can be found in the project archive's uml folder. The img folder contains the class diagram in PNG format. Your program shall implement all of the classes including methods, declaring in stance and class variables, and so on) of this design 3. Class Main. A template source code file for Main is included in the project archive. The Main class shall contain the main() method which shall instantiate an object of the Main class and then call run() on that object. You shall com plete the code by reading the comments and implementing the pseudocode, while using the UML class diagram for Main as a guide. Main.run() shall catch the FileNotFoundException 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 terminate the program. See SR 6. Main.exit() shall catch the FileNotFoundException which may be thrown by Gradebook Writer.writeGradebook() when the gradebook database cannot 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 search() is the last name of a student and search() shall call Roster getStudent) to search the Roster for a student with that last name. If the student is found, it will return a Student object which search() shall return There are five homework assignments, so Main.getNumHomeworks() is a class method which shall return the class constant NUM HOMEWORKS which is declared in Main and is equivalent to 5 Similarly, Main.getNumErams) shall return the class constant NUM_EXAMS which is declared in Main and is equivalent to 3. The remainder of the methods in Main are accessor mutator methods for various data members Class Gradebook Reader. 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 min so that it may be used in the various read methods). Since the file open may fail, this constructor shall throw the FileNotFoundException to Main.run) which shall catch the exception This class reads the gradebook information from the gradebook database file gradebook dat when readGradebook) 19 called. It then calls read Roster to read each student record from the input file and then returns the created Roster object The read Roster) method first instantiates a Roster object, then uses a while loop to read student records from the input file for each student record it reads the student's last and first names from the input file creates a Student maleri//users/dow 12/Documenyspr20202USER2020120J PUJI come To OU . ..ye shall return the class constant NUM EXAMS which is declared in Main and is equivalent to 3. The remainder of the methods in Main are accessor/ mutator methods for various data members. Class Gradebook Reader. 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 min so that it may be used in the various read methods) Since the file open may fail, this constructor shall throw the FileNotFoundException to Main.run() which shall catch the exception This class reads the gradebook information from the gradebook database file gradebook dat when readGradebook() is called. It then calls read Roster() to read each student record from the input file and then returns the created Roster object The read Roster() method first instantiates a Roster object, then uses a while loop to read student records 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- Eram) 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.run() which called readGradebook() in the first place. Note that after reading the Roster but before returning the Roster to Main run(), read Gradebook) calls Roster sort- Roster() to sort the Roster. 5. Class Gradebook Writer. This class writes the gradebook information to gradebook dat before the program exits. It is a subclass of java.io Print Writer so the Gradebook Writer constructor must call the Print Writer constructor to open the file for writing. Since the open may fail, Print Writer will return the FileNotFoundException to Gradebook Writer) which will throw it back to Main erit) which will catch and handle it The gradebook database is written when writeradebook() is called This is a very simple method which just iterates over the Roster, writing each Student object to the file. Class Roster. The class roster is implemented as an ArrayList of Student objects addStudent is called from Grade- book Reader.read Roster) to add a Student to the Roster's ArrayList getStudent() is called from Main. search(), which is called by View.action Performed() when the user clicks the Search button in the View getStudent) calls Searcher search(), passing the Student's last name as the key, search() searches the ArrayList for the student with a matching last name using the binary search algorithm. You shall implement either the iterative 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 sort Roster() is called from Gradebook Reader, see that class for a discussion, sort Roster() calls the class method Sorter. sort) passing the ArrayList of Students as the parameter. Upon return, the ArrayList will 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.toString() is primarily implemented for use as a useful method to call to print out the Roster during debugging. Roster getStudent List() and Roster.setStudent List() are accessor mutator methods for the Student List instance variable 7. Class Searcher. This class shall implement one public class method tnt search(ArrayList pist, 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 either the iterative or recursive binary search 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 Class Sorter. A class which implements the quicksort algorithm. All of the method are static and sorti ArrayList pList) is the only public method and calls private quickSortpust, 0. pList.size() - 1) to sort the list. Template not provided; use the UML class diagram and the quicksort lecture notes. Class Student. The Student class stores the information for one student Read the comments and implement the pse- udocode. See the comments for Student toString() and make sure to implement this method correctly. It is called while writing the gradebook database to write out each Student record. During grading, we will be using the Linux diff command to compare your output files to our output files to check for differences. If there are mismatches, that are more than minor formatting issues, then if the method does not correctly output the Student information, then diff will fail and the test case will fail which will cause you to lose points. 10. Class View The View implements the GUI Read the comments and implement the preudocode Adan ascending order by last name, you shall implement either the iterative or recursive binary search 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 din cram as a guide and the binary search lecture notes Class Sorter. A class which implements the quicksort algorithm. All of the method are static and sort( ArrayList plest) is the only public method and calls private quickSort(pList, 0, pList.size() - 1) to sort the list. Template not provided; use the UML class diagram and the quicksort lecture notes 9. Class Student. The Student class stores the information for one student. Read the comments and implement the pse udocode. See the comments for Student toString() and make sure to implement this method correctly. It is called while writing the gradebook database to write out each Student record. During grading, we will be using the Linux diff command to compare your output files to our output files to check for differences. If there are mismatches, that are more than minor formatting issues, then if the method does not correctly output the Student information, then diff will fail and the test case will fail which will cause you to lose points 10. Class View. The View implements the GUI. Read the comments and implement the pseudocode 5 Additional Project Requirements 1. Format your code neatly. Use proper indentation and spacing Study the examples in the book and the examples the instructor presents in the lectures and posts on the course website 2. Put a comment header block at the top of each method formatted thusly brief description of what the method does 3. Put a comment header block at the top of each source code file formatted thusly // CLASS: classname (classname.java) // CSE205 Object Oriented Programming and Data Structures, semester and year // Project Ilumber: project number // AUTHOR: your name, your ASURITE ID, your email address your email-addr) Prv e rUIVIL Class Diagram This PNG image may be found in the /img subdirectory of the Project 3 zip archive. The UMLet class diagram file can be found in the /uml subdirectory. med ptent face Comparate Sudent compare Tip Student Student In implements maipArgs String : volg e FRAME HEIGHT = 225 und vord searchiplastName String) St Reposer: Robert Carburton Button ExText Text prosent Sant St Exam ArrayListcnteger Firsthame String Homeworst Arrayutinteger mastNamen Studenti Names the SG de core vod HomeScoren ved compareToStudent Student verrides Student Student int get m isteger one feed SaveButton Button Search on Student Name Teid - - - - Performed tv actionut od - display Student Student Student ved Ne SE Numat tom Araylinger gelat i ng gebo g e: String word Studente tt artistuste N ame Svad word me r t bege Student Student Stude Ariston L ootud a cse205-p03.pdf O E file:///C:/Users/dow 12/Documents/Spring%202020/CSE%20205/cse205-p03.pdf lava.awt.event ActionListner action Performed(pEvent: ActionEvent): void interface Comparable Student> compare TopStudent: Student); int 4 implements implements pro 3. Main NUM EXAMS: int=3. const -NUM HOMEWORKS:int: 5 const m Roster: Roster LmView.View +main(Args: String[]): void +exit:void QeNumExams(): int getNum Homeworks(): int -getRoster Roster getView: View run(): void + search(plastName: String): Student -setRoster(pRoster: Roster): void -setView(pView: View): void proi3. Student -Curr Student: Student -mExamList: ArrayList Integer -mFirstName: String mHomeworkList: ArrayList -mlastName String +Student (pFirst Name: String, plastName: String): ector +addExampScore: int): void +addHomework Scoreint): void compare Top Student Student); int override +get Curr Student Student getExampNum: int), int getExamList(): ArrayList void setFirst NamepFirst Name String) void setHomework Numint, pscore int) vod setHomework usthomeworklist: Arrayust Integer voi! setLastName(plastName String void toString: String-override pro View +FRAME WIDTH:int.525 +FRAME HEIGHT Int.: 225 -m Main: Main mClearButton: Button -mExam Text: JTextField() -mExitButton: Button -mHomework Text: JTextField] - mSave Button JButton HmSearchButton JB utton mStudent Name: TextField +ViewipMain: Main): -ctor + action PerformedipEvent ActionEvent): void override- cleart:void clear Numbers) void -display Student Student Student); void -getMain) Main message BoxpMessage: String) void Save Student Student Studenti void -setMainMain: Main} void pro 3. Roster StudentList. ArrayList Student > Rostert ector addStudent Student Studenti: void getStudentplastName: String: Student get Student List ArrayList): vold +setLastName(pLastName: String): void +toString(): String override proi3: Roster mStudentList: ArrayList setStudentListipStudentList: ArrayList object named mStudentList which stores the 17 * information for each student that was read from "gradebook.dat" when the app started. 18 */ 19 public class Roster { * Declare mStudentList as ArrayList ??? SOHN Roster() * PSEUDOCODE: method Roster -- Note that mStudentList was already declared so we do not need to declare it here. -- What we need to do here is create the ArrayList object that mStudentList -- will refer to. create an ArrayList object that mStudentList -- will refer to. create an ArrayList object and then pass that object as the argument to setStudentList() to make mStudentList refer to the ArrayList * end Roster * addStudent() * Adds pstudent to the ArrayList * PSEUDOCODE: * method addStudent (pStudent : Student) : void * add (will append) pStudent to mStudentList * end method ??? getStudent() * Searches mStudentlist for a Student with plastName. * PSEUDOCODE: method getStudent (plastName : String) : Student -- Get the index of the student in the student list index = call Searcher.search(getStudentListo, plastName) Tf indey 15 - 1 then no student with that last name could be found so we return 58 Roster.java X method getStudent (LastName : String) : Student -- Get the index of the student in the student list index = call Searcher.search(getStudentList(), plastName) -- If index is -1 then no student with that last name could be found so we return -- null. Otherwise, we get the Student from the student list at the index and return -- the Student. if index == -1 then return null else return the Student object in getStudentList() at index 'index" * end getStudent ??? 69 700 ** getStudentList Accessor method for mStudentList. NRESSES * Note: it is extremely sleazy to provide public access to the entire private student list * (mStudentList) in this way because it gives whoever calls this method the ability to modify any Student in the roster. It would be better to have the Roster class implement an iterator that would permit other objects to iterate over the elements of the list, but in an effort to keep the project as simple as possible, I am taking the sleazy route. * If you are so inclinded, by all means, implement the iterator public ArrayList getStudentList() { return mStudentList; on 83e publi public ArrayList getStudentList() { return mStudentList; 85 86 878 * setStudentList() 88 89 Mutator method for mStudentList. 90 91 92e private void setStudentList(ArrayList pStudentList) { mStudentList - pStudentList; 94 95 sortRoster * Called to sort the roster by last name. 100 101 102 103 * PSEUDOCODE: * method sort Roster -- Note that all of the methods in Sorter are class methods, so we call the sort -- method on the class Sorter. call Sorter.sort) passing the list of students returned from getStudentlist) * end sortRoster 104 105 106 107 ??? 188 109 110 111 112 113 114- * Returns a String representation of this Roster.toString() methods are very handy for * debugging because given access to a Roster object, say named roster, then you can print the entire roster in one statement: System.out.println(roster); * @Override public String toString() { String result = ""; for (Student student : getStudentList() { result += student + " "; 27 Don 2:1: 101 313M of 497M Smart Insert Read-Only Student.java x 2017 CLASS: Student 11 package proj3; 12 13 import java.util.ArrayList; 150 /** 16 * The Student class stores the gradebook information for one Student. Note that Student implements the java.lang.Comparable Student> interface because we are going to be sorting the roster of students by last name so we need to be able to compare the last * names of two students A and B to determine if A B. See the * compareTo() method. 20 public class Student implements Comparable Student> { * mCurrStudent is a reference to the Student object which is currently being displayed and * edited in the View. It should only be accessed via accessor/mutator methods. ??? mExamlist is an ArrayList of Integers storing the student's exam scores. The student's first name. mExamList is an ArrayList of Integers storing the student's exam scores. ??? * The student's first name. ??? * mHomework List is an ArrayList of Integers storing the student's homework scores. ??? 45 46 47 * The student's lst name. * Student) RANN * PSEUDOCODE: method Student (pFirstName : String, pLastName String) save parameters pFirstName and plastName to instance variables by calling mutators -- Note that we only create the exam list here, it will be populated later create an ArrayList object storing the exam scores. * Since that object is an ArrayList, we next call the get(index) method to retrieve * the correct exam score. 135 136 ??? 137 *getExamList 1385 139 140 141 142 143- 144 * Accessor method for mExamlist. private ArrayList getExamList() { return mExamList; 145 146 147- 148 * getFirstName 150 Accessor method for mFirstName. * Accessor method for mFirstName. public String getFirstName() { return mFirstName; * getFullName) 149 150 151 152e 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 * Returns the student's full name in the format: "lastname, firstname". ??? getHomework) * Accessor method to retrieve a homework score from the list of homeworks. @param pNum The homework number for which we wish to retrieve the score. * @return The homework score. 170 171 172 173 * Hint: Call getHomeworklist to get the ArrayList object storing the hw scores. * Since that object is an ArrayList, we next call the get(index) method to retrieve " the correct hw score. 174 175 176 177 * getHomeworklist() * Accessor method for mHomeworkList. 178 179 180 181 182 -183- 184 185 186 private ArrayList getHomeworkList() { return mHomeworkList; Student.java x 178e 179 * getHomeworkList 180 181 - Accessor method for mHomeworkList. 182 1830 private ArrayList getHomeworkList() { 184 return mHomeworkList; 185 186 187e 188 getLastname) 189 190 * Accessor method for mLastName. 191 1920 public String getLastName() { 193 return mLastName; 194 195 * Mutator method for mCurrStudent. public static void setCurrStudent (Student pCurrStudent) { mCurrStudent = pCurrStudent; 1960 197 198 1995 200 201 202 203 204 205 206 207 208 209 210 * setExam) * Mutator method to store an exam score into the list of exam scores. @pNum is the index into the list of exams, where is the index of the first exam score. 211 -212 * See the hint for getExam(). This method will be similar, but rather than calling get on the ArrayList Integer> object to get a score, we need to call set(index, value) method " to set the value in the ArrayList Integer at index 'index' to 'value'. 213 214 ??? 215 d Student.java X 217 setExamlist() 218 219 * Mutator method for mExamList. 220 2210 private void setExamList(ArrayList pExamlist) { 222 mExamList = pExamList; 223 224 2250 226 * setFirstName() 227 228 * Mutator method for mFirstName. 2302 231 public void setFirstName(String pFirstName) { mFirstName - pFirstName; 235 setHomework() 236 237 * Mutator method to store a homework score into the list of homework scores. 238 239 pNum is the index into the list of homeworks, where is the index of the first hw score. 240 241 242 243 * See the hint for getHomework(). This method will be similar, but rather than calling get() on the ArrayList object to get a score, we need to call set(index, value) method * to set the value in the ArrayList phomeworklist) { HomeworkList - pHomeworkList; 253 254 255 Studentjava X 254 255 2560 257 setLastname() * Mutator method for mLast Name 258 259 260 261e 262 263 264 2659 266 267 public void setLastName(String pLast Name) { Last Name - plastName; *toString 268 Returns a String representation of this student. The format of the returned string shall be such that the Student information can be printed to the output file in this format: 269 270 271 272 273 lastname firstname examl exam2 exam2 hwl hw2 hw 3 hwn hw5 where the fields are separated by spaces, except there is not space following hw5. 274 275 276 Hint: The String class has a method named trin) that removes leading and trailing white- space from a string. 277 278 Hint: use enhanced for loops 279 280 281 282 @Override public String toString() { String result = getLastName() + " " + getFirstName() + for (Integer exam : get ExamList() { result += exam + " "; 283 28.14 285 286 282 288 289 290 for (Integer hw : getHomeworklist()) { result + hw + " "; return result.trim(); 291) 292 View.java 3 2e\/ CLASS: View 11 package proj3; 12 13e import java.awt.event.ActionEvent;, 22 23e/** 24 - The View class implements the GUI. It is a subclass of JFrame and implements the ActionListener 25 interface so that we can respond to user-initiated GUI events. 26 / 27 public class View extends JFrame implements ActionListener { * The width of the View frame. ??? * The height of the View frame. * When the View() ctor is called from Main.run() to create the View, run passes a reference * to the Main object as the argument to View(). We save that reference into main and then later we can use mMain to communicate with the Main class. * main is made accessible within this class via accessor/mutator methods getMain() and * setMain(). It shall not be directly accessed. " Declare GUI related instance variables for the buttons and text fields. ??? View.java When the View() ctor is called from Main.run() to create the View, run() passes a reference to the Main object as the argument to View(). We save that reference into main and then * later we can use main to communicate with the Main class. main is made accessible within this class via accessor/mutator methods getMain() and . setMain(). It shall not be directly accessed. Declare GUI related instance variables for the buttons and text fields. View) The View constructor creates the GUI interface and makes the frame visible at the end. * para pain is an instance of the Main class. This links the view to the Main class so * they may communicate with each other. public View(Main pMain) { * Save a reference to the main object pain into instance var main by calling setMain). setMain(Main); PSEUDOCODE: // Create a JPanel named panelSearch which uses the FlowLayout 11 Add a JLabel "Student Name: to panelSearch // Create Student Name and make the field 25 cols wide 1 Add StudentName to the panel // Create SearchButton with the label "Search" Make this View the action listener for the button 11 Add the button to the panel ??? View.java X 79 80 // PSEUDOCODE: // Create a JPanel named panel Homework which uses the FlowLayout // Add a JLabel "Homework: " to the panel // Create HomeworkText which is an array of JTextFields, one for each homework assignment // For i = o to the number of homework assignments Do // Create a textfield mHomeworkText[i] displaying 5 cols Add mHomeworkText[i] to the panel // End For // Note: DO NOT HARDCODE THE NUMBER OF HOMEWORK ASSIGNMENTS 1/ ??? // Create the exam panel which contains the "Exam: "label and the two exam text fields. // The pseudocode is omitted because this code is very similar to the code that creates the // panel Homework panel above. // Note: DO NOT HARDCODE THE NUMBER OF EXAMS ??? 1/ PSEUDOCODE: // Create a JPanel named panelButtons using FlowLayout 17 Create the clear button ClearButton labeled "Clear 17 Make this view the action listener for ClearButton // Add the clear button to the panel 17 Repeat the three above statements for the Save button // Repeat the three above statements for the Exit button ??? 1PSEUDOCODE: // Create a Panel named panelMain using a vertical BoxLayout 11 Add panelSearch to panelMain 1 Add panelHomework to panelMain 11 Add panelexam to panelMain 71 Add panelButtons to panelain ??? Set the title of the view to whatever you want by calling setTitle set Title("Gred + Gradebook Editor"); FRAME_HEIGHT 1/ Set the size of the view to FRAME_WIOTH View.java X 112 // Set the title of the View to whatever you want by calling setTitle() setTitle("Gred 1: Gradebook Editor"); 115 1/ Set the size of the View to FRAME_WIDTH X FRAME_HEIGHT setSize(FRAME WIDTH, FRAME_HEIGHT); // Make the view non-resizable setResizable(false); // Set the default close operation to JFrame.DO_NOTHING_ON_CLOSE. This disables the X close 11 button in the title bar of the View so now the only way to exit the program is by click- // ing the Exit button. This ensures that Main.exit() will be called so it will write the 77 student records back out to the gradebook database. // Add panelMain to the view. add(panelMain); 77 If you are a Mac user, you may need to call the pack() method which is inherited from 1 java.awt. Window() now to pack the view before displaying it. Windows and Linux users do 77 not need to do this, although if you do, it will not cause any problems. >>> 1 Now display the view by calling setvisible(). setVisible(true); actionPerformed Colled when one of the Buttons is clicked. Detects which button was clicked and handles i Make sure to write the verride annotation to prevent accidental overloading because we are overriding JFrame.actionPerformed PSEUDOCODE: method actionPerformed (Event ActionEvent) VO 322M of 497M 2:1: 101 Smart Insert Read-Only View.java 3 LOLU w UI JOULLUTS 15 LLLREU. LELLS WILLI UULLUT > LLLU na 144 145 146 147 Make sure to write the Override annotation to prevent accidental overloading because we are overriding JFrame.actionPerformed(). 148 150 151 152 153 154 155 156 157 PSEUDOCOODE: * method actionPerformed (pEvent : ActionEvent) : void If the source of the event was the Search button Then Clear the numbers in the homework and exam fields lastName - retrieve the text from the mStudentName text field If lastName is the empty string Then Call messageBox() to display "Please enter the student's last name Else -- Main contains a method named search() which given the last name of a student will search the Roster for the student. search() either returns the Student -object if found, or if there is no student with that last name in the Roster, -- then search() returns null. Call getMain().search(lastName) and pass the return value to Student.setCurrStudent() If the curr student object saved in the Student class is null Then Call messageBox() to display "Student not found. Try again." Else Retrieve the cure student from the Student class and pass it to displayStudent) End If End If 159 160 161 162 163 164 165 166 167 168 17e - Else if the source of the event was the Save button Then If Student.getCurrStudent is not null Then Call SaveStudent (Student.getCurrstudent()) * Else if the source of the event was the clear button Then Call clear 171 172 173 Else if the source of the event was the Exit button then If Student.getCurrstudent is not null Then Call SaveStudent (Student.getCurrStudent) Call getMain().exit() to terminate the application - End If end actionPerformed Read-Only Smart Insert 2:1:101 327M of 497M Type here to search E View.java 3 180 ??? 181 182 183 - clear() 184 * Called when the Clear button is clicked. Clears all of the text fields by setting the 186 * contents of each to the empty string. 185 187 188 . After clear() returns, no student information is being edited or displayed and mStudent * has been set to null. 189 190 191 192 193 - PSEUDOCODE: method clear() : void Set the Student Name text field to clear the numbers in the homework and exam fields by calling clearNumbers) Set the current Student object in the Student class to null end clear 194 195 196 198 199 200 201 clearlumbers) 202 203 Clears the homework and exam fields 205 DO NOT HARCODE THE NUMBER OF HOMEWORKS AND EXAMS. Call the constant accessor methods in 206 207 203 209 210- 212 213 -214 displayStudent) Displays the homework and exam scores for a student in the momeworkText and Exam Text text fields parapStudent is the student who's scores we are going to use to populate the text fields. EGEN PSEUDOCODE Read-Only Smart Insert 2:1 101 334M of 497M Tune here to search RIW AL View.java X 191 192 193 194 * PSEUDOCODE: * method clear() : void Set the Student Name text field to Clear the numbers in the homework and exam fields by calling clearNumbers Set the current Student object in the Student class to null * end clear 195 196 197 198 ??? 199 * clearNumbers * Clears the homework and exam fields. 2ee 201 202 203 204 205 206 207 2e8 209 2105 * DO NOT HARCODE THE NUMBER OF HOMEWORKS AND EXAMS. Call the constant accessor methods in Main. ??? 211 212 * displayStudent) Displays the homework and exam scores for a student in the HomeworkText and ExamText text * fields. 214 215 215 param pStudent is the Student who's scores we are going to use to populate the text fields. 217 218 219 220 221 222 PSEUDOCODE: method displayStudent (pStudent Student) : void For i = 0 to Main.getNumhomeworks I Do int hw = pStudent.getHomework(1) String hwstr = convert hw to a String (Hint: Integer toString) mhomeworkText[1].setText (hwstr) End For Write a similar for loop to place the student's exams scores into the text fields end display Student 223 224 225 226 222 228 * DO NOT HARCODE THE NUMBER OF HOMEWORKS AND EXAMS. Call the constant accessor methods in 2:1:101 341M of 497M Smart Insert Read-Only View.java X 232 233 Accessor method for main. 234 private Main getMain() { return main; messageBox() 236 237 238 239e 240 241 242 243 244 245 246 247 Displays a message box containing some text. Note: read the Java 8 API p

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started