Assigment-02 Generics in Java.docx
Assigment-02 Generics in Java.docx
<<generic>> TextEditor<T>
+ TextEditor(capacity: int)
+ add(obj: T): void
+ display(): void
+ undo(): void
○ This is a generic class that allows storing and managing objects of any type
(T) in a text editor.
○ Fields:
○ Methods:
1. Add Data: Allow users to add data of any type (Integer, String, Float,
Double) into the editor.
2. Display Data: Display all objects stored in the editor.
3. Undo Last Action: Remove the most recently added object (undo functionality).
4. Use Generics:
○ The class should work with any data type.
5. Array-Based Design:
○ No external libraries or data structures (e.g., ArrayList, Stack). Use a
normal array.
6. Menu-Driven Program:
○ Provide options to add data, display all objects, undo the last action, and
exit.