

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A lab exercise for cpsc 215l students in the fall 2008 semester. The lab focuses on gaining experience with generics in java and implementing best practices to prevent privacy leaks. The exercise consists of two parts: the first part is collaborative and involves creating classes ink and pen, while the second part is individual and requires modifying the stack interface and implementation to be generic. Students are expected to write safe copy constructors, parameterized constructors, and getter and setter methods for the classes ink and pen, and to test their implementation by changing the quantity of the ink object and checking if the values are the same.
Typology: Lab Reports
1 / 2
This page cannot be seen from the preview
Don't miss anything!
CpSc 215L, Section 002 Fall 2008
The purpose of this lab is to give you some experience working with generics in Java as well as using best practices to avoid “privacy leak”.
For this lab, you are required to have the Stack interface as well as one of your interface implementations. The lab is divided into two parts. The first part should be done collaboratively in pairs. The second part should be done individually.
For the collaborative part, you are required to implement the class Ink which includes the following member variables:
Additionally, you are required to create the class Pen that has the following member variables:
For both classes, you are required to use the Color enumeration covered in the code handouts provided in class. For the Ink class, provide a safe copy constructor that takes an object of the same class as argument. For the Pen class, provide a safe parameterized constructor that takes the different member variables as arguments. For both classes provided safe getter and setter methods for the different member variables.
To test your implementation, in your main method do the following following:
Note: Make sure all your member variables are private.
CpSc 215L, Section 002 Fall 2008
For the individual part, you are required to change the stack interface that you have previously developed to be generic. Additionally, change one of your stack implementation classes to implement the interface and be generic as well.
To test your implementation, in your main method do the following:
Good Luck!