Design a class named Fan to represent a fan. The class contains: a. An int data field named speed that specifies the speed of the fan. A fan has speeds indicated with a value 1, 2, or 3. b. A bool data field named on that specifies whether the fan is on. c. A double data field named radius that specifies the radius of the fan. d. A no-arg constructor that creates a default fan with speed 1, on false, and radius 5. e. The accessor and mutator functions for all the data fields.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 11PE
icon
Related questions
Question

in c++

Design a class named Fan to represent a fan. The class contains:
a. An int data field named speed that specifies the speed of the fan. A fan has three
speeds indicated with a value 1, 2, or 3.
b. A bool data field named on that specifies whether the fan is on.
c. A double data field named radius that specifies the radius of the fan.
d. A no-arg constructor that creates a default fan with speed 1, on false, and
radius 5.
e. The accessor and mutator functions for all the data fields.
Draw the UML diagram for the class. Implement the class. Write a test program
that creates two Fan objects. Assign speed 3, radius 10, and turn it on to the first
object. Assign speed 2, radius 5, and turn it off to the second object. Invoke their
accessor functions to display the fan properties.
Transcribed Image Text:Design a class named Fan to represent a fan. The class contains: a. An int data field named speed that specifies the speed of the fan. A fan has three speeds indicated with a value 1, 2, or 3. b. A bool data field named on that specifies whether the fan is on. c. A double data field named radius that specifies the radius of the fan. d. A no-arg constructor that creates a default fan with speed 1, on false, and radius 5. e. The accessor and mutator functions for all the data fields. Draw the UML diagram for the class. Implement the class. Write a test program that creates two Fan objects. Assign speed 3, radius 10, and turn it on to the first object. Assign speed 2, radius 5, and turn it off to the second object. Invoke their accessor functions to display the fan properties.
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Class
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,