Computer Science Division 3rd Level Students - CS
Department of Mathematics Course: COMP 301
Faculty of Science Date: December 27th, 2021
Sheet 10
Aims:
-Students should know how:
• Manipulate ArrayList in Java
• Develop a GUI program that manipulate ArrayList
Exercise 1:
Write a GUI program that stores some names in an ArrayList of String. The program should
looks like the following fig
After clicking any of the three buttons, the result appears in the second text field (whether the
number of the entered names in the array list, or the index of the searched name) with an
appropriate label.
Exercise 2:
Develop a GUI program that stores some numbers into an ArrayList of Integer and make some
operations on them. The program should look like the following fig:
1|Page
Computer Science Division 3rd Level Students - CS
Department of Mathematics Course: COMP 301
Faculty of Science Date: December 27th, 2021
• When clicking on the Add button, the number x is inserted at the end of the ArrayList.
• When clicking on the Add At button, the number x is inserted at the position index at the
ArrayList (if avaliable).
• When clicking on the Delete button, the number x is deleted from the ArrayList (if exist).
• When clicking on the Delete At button, the number at position index is deleted from the
ArrayList (if available).
• When clicking on the Search button, the position of the number x in the ArrayList is
returned (or an error message if it does not exist).
• When clicking on the Replace button, the number at position index in the ArrayList is
replaced by the number x.
• When clicking on the show button, all the numbers at the ArrayList are displayed
• In all the above events; a description message should appear at the TextArea (white area)
and a sketch of the ArrayList appears at the panel (green area). The following figure
illustrates what happens when clicking on the Add button also when clicking Search button
2|Page
Computer Science Division 3rd Level Students - CS
Department of Mathematics Course: COMP 301
Faculty of Science Date: December 27th, 2021
3|Page
Computer Science Division 3rd Level Students - CS
Department of Mathematics Course: COMP 301
Faculty of Science Date: December 27th, 2021
Exercise 3: (Assignment)
Develop a GUI program that stores data of some students into an ArrayList of class Student and
make some operations on them. The program should look like the following fig:
Given That:
class Student
{
int id, totalMark;
String name;
Student (int d, String n, int m)
{
id = d ; name = n ; totalMark = m;
}
// You can add any other useful methods to help you
}
4|Page