This challenge should be clarified. The student is asked to write a getter, and a setter, but the goal of the code is unclear. After looking at the example code it seems the point is to convert fahrenheit to celsius, which is really not expressed well in the challenge.
The temperature scale used inside of the object is not important at all. The user-facing behavior of the getter and setter is specified in the challenge description. The getter must provide the temp in Celsius. The setter must take a temp in Celsius. The constructor must take a temp in Fahrenheit. The user can write any internal code that meets those three requirements.
Use the
class
keyword to create aThermostat
class.
The
constructor
accepts a Fahrenheit temperature.
In the class, create a
getter
to obtain the temperature in Celsius and asetter
to set the temperature in Celsius.
Note: When you implement this, you will track the temperature inside the class in one scale, either Fahrenheit or Celsius.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.