10
Tarea
Java Core, nivel 8, lección 8
Wrapper (Decorator)
Figure out what the program does.
By analogy with the DecoratorRunnableImpl class, create a DecoratorMyRunnableImpl class.
10
Tarea
Java Core, nivel 8, lección 8
Extending AmigoOutputStream
Using the wrapper (decorator) design pattern, extend the functionality of AmigoOutputStream.
In the QuestionFileOutputStream class, the following functionality should be implemented for the close() method:
1. Display "Do you really want to close the stream? Y/N".
2. Read a line.
3. If the read line
10
Tarea
Java Core, nivel 8, lección 8
AmigoOutputStream
1 Change the AmigoOutputStream class so that it wraps the FileOutputStream class. Use inheritance.
2 When the close() method is called, perform the following sequence of actions:
2.1 Call the flush() method.
2.2 Append the following text "CodeGym © All rights reserved." Use the getBytes() method.
2.
10
Tarea
Java Core, nivel 8, lección 8
UnsupportedFileName
Change the TxtInputStream class so that it only works with txt files (* .txt).
For example, first.txt or name.1.part3.txt.
If a non-txt file is passed (e.g. file.txt.exe), then the constructor should throw an UnsupportedFileNameException.
Think about what else you need to do if an exception is throw
10
Tarea
Java Core, nivel 8, lección 8
Table
Change the TableInterfaceWrapper class so that it wraps TableInterface.
The setModel method should display the number of elements in the new list before updating the model.
The getHeaderText method should return the text in upper case. Use the toUpperCase() method.