Consider a class "Fan" with two integer data members, "state" (0/1 i.e. on or off) and "speed". 1. Write a parameterized Constructor for this class. 2. Write a member function "changeState( )" which behaves similar to pressing a button i.e. it should change the state of the fan. If it is off (0), calling the function should turn it on (1) and vice versa

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 15PE
icon
Related questions
Question

Consider a class "Fan" with two integer data members, "state" (0/1 i.e. on or off) and "speed".

1. Write a parameterized Constructor for this class.

2. Write a member function "changeState( )" which behaves similar to pressing a button i.e. it should change the state of the fan. If it is off (0), calling the function should turn it on (1) and vice versa.. Multi Line Text.

 
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Software Development
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT