October 22, 2019
You will study and modify a class for chemical elements (consult https://en.wikipedia.org/wiki/List_of_chemical_elements#List for a complete list).
Download ChemElemProject, extract the project, open it in VS, compile and execute it. Now read the code in “ChemElem.cs” and “Program.cs”.
The class definition “ChemElem.cs” contains:
ToString method.The application program “Program.cs” performs one simple conversion from Kelvin to Celsius, using data given by the user, create and display a ChemElem object (implicitely calling the ToString method).
Do the following:
ToString method when it is called by the object you created at the previous step.FromKelvinToCelsius method with one of your object, for instance using hydrogen.FromKelvinToCelsius(34). What happens?MeltingInCelsius method with the class, for instance using ChemElem.MeltingInCelsius();. What happens?We now want to significantly improve this class, by adding
You may want to comment part, of all of your “Program.cs” file, before starting to change your class.
FromKelvinToFahrenheit method, taking inspiration from the FromKelvinToCelsius method.MeltingInFahrenheit method, that returns the melting point in Fahrenheit of the calling object. This method should use your FromKelvinToFahrenheit method.BoilingInFahrenheit method, that return the boiling point in Fahrenheit of the calling object. This method should use your FromKelvinToFahrenheit method.ToString method, so that the string returned includes
You should test all of those modifications in your “Program.cs” file as you implement them. Use relevant data, test your program, and make sure the behaviour is the expected behaviour.