[Solved]-Question 2 Write Java Application Following Mvc Design Model Application Consist Four Clas Q37202895
Please answer Question 2.
Question 2: Write java application following the MVC design model. The application should consist of four classes: GUI, Controller, Student, and the main. The code of class Student it given below while you should write the code for the remaining classes. GUI class: use any layout manager to generate the above GUI interface. Controller: The controller class has an ArrayList of three students (Ahmed, ID: 123), (Salma, ID: 456), (Hamad, ID:789). The combo box should be initialized with the names of the three students inside the constructor of the controller class. The controller should listen to all of the four buttons in the GUI interface. o Add: When the user clicks on the Add button, the application should search for the user in the vector, and once it is found, it adds the course to the student by calling the method addCourse in class Student. The application also shows in the text area a confirmation message indicating that the course was added. Drop: When the user clicks on the Drop button, the application should search for the user in the vector, and once it is found, it drops the course by calling the method dropCourse in class student. The application also shows in the text area the status message returned from the method dropCourse to indicate whether the course successfully dropped or not o o Clear: When the user clicks on the Clear button, the application should clear the text field and the text area. o Show Details: When the user clicks on the button Show Details, the application should show in the text area the details of the student by calling the method toString of the class Student. Main: As usual, the main class: (1) creates an object of class GUI, (2) it creates an object from the Controller class with the GUI object sent as a parameter, (3) it registers the controller object as an action listener to all buttons declared in the GUI class. public class Student private String fullName rivate String id; ArrayList <String> courses new ArrayList <> lic Student (String n, String i) fullName n; public void addCourse (String course) courses.add (course); lic String Dro String statusMessage- int index = -1; for (String c:courses) [ rse (String course) if (c.equals (course)) index courses. indexOf (c) ; if (index–1) courses.remove (index) statusMessageThe Course “+ course +” was successfully dropped for”+fullName elsef statusMessage-“Course “+courset” doesn’t exist in the student’s list!” return statusMessage; ublic String getFul1Name ) return fullName; lic String toString O String stDetails fullName”,” String allcourses for (int í=0;i<courses . size ( );i++){ id allCourses allcourses +”,”+ courses. get ( i ) ; stDetails-stDetailsallCourses; return stDetails; Show transcribed image text Question 2: Write java application following the MVC design model. The application should consist of four classes: GUI, Controller, Student, and the main. The code of class Student it given below while you should write the code for the remaining classes. GUI class: use any layout manager to generate the above GUI interface. Controller: The controller class has an ArrayList of three students (Ahmed, ID: 123), (Salma, ID: 456), (Hamad, ID:789). The combo box should be initialized with the names of the three students inside the constructor of the controller class. The controller should listen to all of the four buttons in the GUI interface. o Add: When the user clicks on the Add button, the application should search for the user in the vector, and once it is found, it adds the course to the student by calling the method addCourse in class Student. The application also shows in the text area a confirmation message indicating that the course was added. Drop: When the user clicks on the Drop button, the application should search for the user in the vector, and once it is found, it drops the course by calling the method dropCourse in class student. The application also shows in the text area the status message returned from the method dropCourse to indicate whether the course successfully dropped or not o o Clear: When the user clicks on the Clear button, the application should clear the text field and the text area. o Show Details: When the user clicks on the button Show Details, the application should show in the text area the details of the student by calling the method toString of the class Student. Main: As usual, the main class: (1) creates an object of class GUI, (2) it creates an object from the Controller class with the GUI object sent as a parameter, (3) it registers the controller object as an action listener to all buttons declared in the GUI class.
public class Student private String fullName rivate String id; ArrayList courses new ArrayList lic Student (String n, String i) fullName n; public void addCourse (String course) courses.add (course); lic String Dro String statusMessage- int index = -1; for (String c:courses) [ rse (String course) if (c.equals (course)) index courses. indexOf (c) ; if (index–1) courses.remove (index) statusMessageThe Course “+ course +” was successfully dropped for”+fullName elsef statusMessage-“Course “+courset” doesn’t exist in the student’s list!” return statusMessage; ublic String getFul1Name ) return fullName; lic String toString O String stDetails fullName”,” String allcourses for (int í=0;i
Expert Answer
Answer to Question 2: Write java application following the MVC design model. The application should consist of four classes: GUI, … . . .
OR

