(Lab-1 Manual) CS-204-DSA - Interfaces, and The ArrayList Class
(Lab-1 Manual) CS-204-DSA - Interfaces, and The ArrayList Class
Fall 2020
v1.0
3/27/2019
Lab-1 Manual 2019
Now open and observe that the class BankAccount implements this interface and provides an
implementation of the compareTo method that compares two account objects based on their
balance. Study this class and understand how the compareTo method is written. Note that we
must cast the BankAccount object from Object as in line # 2 of this method.
Finally, open the UsingBankAcconts class where a test program is written for you that compares
different BankAccount objects.
Page 1
Lab-1 Manual 2019
NOTE: Write your classes and the main method in separate files.
Page 2
Lab-1 Manual 2019
Convert the given UML diagram into classes. Note that bold methods represent overridden
methods in the below given UML diagram.
1. Create all classes having names as per the above diagram, and UsingStudents.java
having the main method.
2. Inside the main method, create 5 Student objects using the overloaded constructor.
Assign appropriate values to the state of all instances.
3. Display the state of all objects.
4. Demonstrate the use of compareTo method and compare these objects. Display the
outputs using appropriate messages.
Page 3
Lab-1 Manual 2019
Page 4
Lab-1 Manual 2019
Page 5
Lab-1 Manual 2019
1. Open the Lab Code folder. Find the Measurable interface and the Student class in that
folder.
2. Complete the implementation of the Student class.
3. Create an UsingStudents class having the main method.
4. Inside the main method, create an ArrayList of at least 5 Student objects using the
overloaded constructor. Assign appropriate values to the state of all instances.
5. Display the state of all objects.
6. Demonstrate the use of all methods as given in the Measurable interface using
appropriate messages.
Page 6