Abstract Factory Method Lab 1
Lab: Extending the GUI System
Objective:
In this lab, you will extend the provided GUI System application by adding a new GUI control.
Instructions:
Review the provided GUI System application. This application currently supports creating and rendering Windows and MacOS style buttons and checkboxes through the use of an Abstract Factory pattern.
Add a new GUI control:
Slider
. This will require creating a newSlider
interface in the same way as theButton
andCheckbox
interfaces.The
Slider
interface should declare arender()
method.
Create new concrete
Slider
classes:WindowsSlider
andMacOSSlider
.These classes should implement the
Slider
interface and override therender()
method. The method should print "Rendering Windows/MacOS style slider..." to the console.
Update the
GUIFactory
interface to include a new method:createSlider()
.Update the
WindowsGUIFactory
andMacOSGUIFactory
classes to override thecreateSlider()
method. The method should return a new instance ofWindowsSlider
orMacOSSlider
respectively.Update the
Client
class to create and render aSlider
in addition to aButton
andCheckbox
. It should do this for both Windows and MacOS styles.Test your application to ensure it behaves as expected.
Tips:
Remember, the Abstract Factory pattern is about creating an interface for creating families of related objects, but allowing the subclasses to decide which classes to instantiate.
Submission:
You should submit your completed Java files for Button
, Checkbox
, Slider
, WindowsButton
, WindowsCheckbox
, WindowsSlider
, MacOSButton
, MacOSCheckbox
, MacOSSlider
, GUIFactory
, WindowsGUIFactory
, MacOSGUIFactory
, and Client
.
Remember, the goal of this lab is to understand the Abstract Factory pattern and how it can be used to provide a flexible interface for creating new families of related objects. Good luck!