The following table lists the freezing and boiling points of several substances.
Substance
Freezing Point
Boiling Point
Ethyl Alcohol
-173
172
Oxygen
-362
-306
Water
32
212
Design a class that stores a temperature in a temperature field and has the appropriate accessor andmutator methods for the field. In addition to appropriate constructors, the class should have the following methods:
isEthylFreezing. This method should return the boolean value true if the temperature stored in the temperature field is at or below the freezing point of ethyl alcohol. Otherwise, the method should return false.
isEthylBoiling. This methodshould return the boolean value true if the temperature stored in the temperature field is at or above the boiling point of ethyl alcohol. Otherwise, the method should return false.
isOxygenFreezing. This method should return the boolean value true if the temperature stored in the temperature field is at or below the freezing point of oxygen. Otherwise, the method should return false.
isOxygenBoiling. This method should return the boolean value true if the temperature stored in temperature field is at or above the boiling point of oxygen. Otherwise,the method should return false.
isWaterFreezing. This method should return the boolean value true if the temperature stored in the temperature field is at or below the freezing point of water. Otherwise, the method should return false.
isWaterBoiling. This method should return the boolean value true if the temperature stored in the temperature field is at or above the boiling point of water. Otherwise, the method should return false.
Write a program that demonstrate the class. The program should ask the user to enter a temperature, and then display a list of the substance that will freeze at that temperature and those that will boil at that temperature. For example, if the temperature is -20 the class should report that water will freeze and oxygen will boil at that temperature.
Breaking it down
FreezeAndBoiling class
Program demonstration
Output
Unit tests
Level Up
In each of the freezing or boiling methods, check that the method parameters are valid. Write a unit test to validate the behavior you implemented.
There is a consitent pattern of elements on if it will freeze and boil. While the FreezeAndBoiling performs a specific behavior, it isn't set up to adapt to new elements. Refactor existing code to use a Enum.
Each of the freezing and boiling methods we wrote a positive test to validate if it met a condition. Write the negative test for each method validating the false behavior.