From the course: Object-Oriented Programming with C++
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Challenge: Implementing a smart home thermostat class - C++ Tutorial
From the course: Object-Oriented Programming with C++
Challenge: Implementing a smart home thermostat class
(upbeat music) - [Instructor] Here's a coding challenge to test your understanding of classes, member variables, access modifiers, constructors, and disruptors. Your task is to implement a basic thermostat class that mimics a smart home thermostat. The class should include the following: a member variable temperature of type float, which represents the current temperature setting of the thermostat in degrees Celsius or Fahrenheit. A mode variable of unsigned in type, representing the mode of the thermostat. Zero for off, one for cooling, two for heating. And a member variable for location of type string for the location of the thermostat, such as living room or bedroom. The class should also have a public method that prints the current setting of the thermostat, including the temperature, mode, and location. Additionally, implement a constructor that takes initial values for the temperature mode and location, and assigns them to the member variables. Finally, add a disruptor that…
Contents
-
-
-
Defining classes2m 38s
-
(Locked)
Access specifiers3m 33s
-
(Locked)
Separating class declaration from class definition3m 42s
-
(Locked)
Creating and using objects2m 29s
-
(Locked)
Constructors and destructors5m 23s
-
(Locked)
Challenge: Implementing a smart home thermostat class1m 55s
-
(Locked)
Solution: Implementing a smart home thermostat class1m 50s
-
-
-
-
-
-