Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Simple Compound Pattern program. Code for program can be written using Java, C#, or C++ The ceiling fan represents are real world model

Write a Simple Compound Pattern program.

Code for program can be written using Java, C#, or C++

The ceiling fan represents are real world model of patterns working together. Please implement a ceiling fan that has the speeds of high, medium, low and off. This fan needs to come with a remote control with four buttons that can be programmed. For this exercise, program the buttons to:

Button One:

On: set fan to high

Off: Turn fan off

Button Two:

On: set fan to medium

Off: Turn fan off

Button Three:

On: set fan to low

Off: turn fan off

Button Four:

On: set fan cycle (each click will cycle to the next speed. Example: If fan is at high, the next click will move the speed to medium. The next click will move it to low. The next click will move it back to high)

Off: turn fan off

Hint:

There are two things going on here. There are commands that are being transmitted and need to be remembered (Command Pattern), and there is state (State Pattern). The remote-control button commands could be stored in a collection type, such as arrays.

You have full freedom to design and implement this solution as you see fit. The only requirements are that the user should be able to use the remote control (from the driver program) to cycle through all permutations of the fan states. You also need use at least two patterns, and you will need test and comment your code, and document your design with UML class hierarchy diagram(s).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions