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:

  1. 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.

  2. Add a new GUI control: Slider. This will require creating a new Slider interface in the same way as the Button and Checkbox interfaces.

    • The Slider interface should declare a render() method.

  3. Create new concrete Slider classes: WindowsSlider and MacOSSlider.

    • These classes should implement the Slider interface and override the render() method. The method should print "Rendering Windows/MacOS style slider..." to the console.

  4. Update the GUIFactory interface to include a new method: createSlider().

  5. Update the WindowsGUIFactory and MacOSGUIFactory classes to override the createSlider() method. The method should return a new instance of WindowsSlider or MacOSSlider respectively.

  6. Update the Client class to create and render a Slider in addition to a Button and Checkbox. It should do this for both Windows and MacOS styles.

  7. 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!