Question: Lab 5.2 A Window Class (Window) Code the following Window class: The (abstract) Window class represents a window with a height and width, as well
Lab 5.2 A Window Class (Window)
Code the following Window class:
The (abstract) Window class represents a window with a height and width, as well as the status of the window: normal (also known as 'restored') or minimized. In minimized mode, the window's toString result is displayed in a 1-line collapsed fashion (reminiscent of minimizing a window to the task bar):
[ a 7 x 5 minimal window (minimized) ]
while displaying the window in 'normal' (or 'restored') depends on the type of window, and thus is deferred to the subclasses (by making it an abstract method ofWindow). Specification:
maintains height and width, and whether the window is minimized
has a display method that displays the window in either normal or minimized mode.
if the window is not visible (regardless of minimized more), the string (Nothing to see here) is displayed
in minimized mode, the display is single line consisting of the toString result for the object, followed by '(minimized)' and surrounded by '[]'s (see below).
has setVisible and isVisible methods
has an abstract displayNormal method.
This will be overridden by your classes in the 5.3 and 5.4, and is being overridden in this exercise by MinWindow
has a resize method that accepts a width and height and sets the window's width and height to those values.
has getHeight and getWidth methods
has minimize and restore methods
I've provided an application class, WindowApp, for testing your class, and, as discussed above, a MinWindow class that provides a minimal implementation of a displayNormal method. THis minimal window class has a self-describing toString that also contains the width and height.
Sample Test Run
For example if the file window.data contains:
7 12
the provided WindowApp application class (using the MinWindow) class produces the following output:
Creating a 5x10 minimal window Displaying: (Nothing to see here) Setting visible to true and displaying: ....................... :a 5x10 minimal window: ....................... Minimizing and displaying: [a 5x10 minimal window (minimized)] Restoring and displaying: ....................... :a 5x10 minimal window: ....................... Resizing to 10x5 and displaying: ....................... :a 10x5 minimal window: ....................... Minimizing and displaying: [a 10x5 minimal window (minimized)] Creating a window from file data and displaying (Nothing to see here) Setting visible to true and displaying: ....................... :a 7x12 minimal window: ....................... Minimizing and displaying: [a 7x12 minimal window (minimized)]
Submitting to CodeLab
Please remove public from your Window class header.
In Codelab I will be providing the application and minimal classes. Please submit just the code for the Window interface.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
