Changes

Jump to: navigation, search
no edit summary
=== 7. Implement Delete Student option ===
7.1. In the <code>ViewStudentApp</code> implement <code>DeleteCommandHandler</code> by adding anonymous class:
<presource lang="java">
deleteItem.setCommand(new Command(new CommandHandler(){
public void execute(ReadOnlyCommandMetadata metadata, Object context) {
}
}));
</presource>
7.2. Add the <code>deleteElement()</code> method to the <code>StudentList</code> class:
<presource lang="java">
void deleteElement(Object element) {
doRemove(element);
}
</presource>
7.3. Run the application, select one student and select "'''Delete Student'''" from the menu:<br/>
[[Image: BB_delete1.png | 300px]]<br/>
[[Image: BB_delete3.png | 300px]]<br/>
7.6. Add "''Delete Student''" as option in view screen. Change the one argument constructor of the anonymous class to two argument constructor:
<presource lang="java">
InfoScreen(final Student student, final StudentList studentList) { }
</presource>
7.7. Add <code>MenuItem</code> to this screen menu and implement <code>CommandHandler</code>:
<presource lang="java">
MenuItem deleteItem = new MenuItem(new StringProvider("Delete Student"), 400, 4);
deleteItem.setCommand(new Command(new CommandHandler(){
}));
addMenuItem(deleteItem);
</presource>
7.8. Run the application, select a student and inside the View Screen go to the menu and select "'''Delete Student'''": <br/>
[[Image: BB_delete4.png | 300px]]<br/>
7.9. Repeat the same steps as for the Main Screen. When you are done you should be redirected to Main Screen.
1
edit

Navigation menu