You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: labs/ChemicalElements/readme.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,20 +10,20 @@ This lab serves multiple goals:
10
10
11
11
# A Class for Chemical Elements
12
12
13
-
In this lab you will study and modify a class for [chemical elements](https://en.wikipedia.org/wiki/Chemical_element).
13
+
In this lab, you will study and modify a class for [chemical elements](https://en.wikipedia.org/wiki/Chemical_element).
14
14
Consult <https://en.wikipedia.org/wiki/List_of_chemical_elements#List> for a complete list of all elements.
15
15
16
16
## Reading
17
17
18
-
Download [ChemElemProject](ChemicalElements.zip) and extract the project. Open it in in your IDE, compile and execute it.
18
+
Download [ChemElemProject](ChemicalElements.zip) and extract the project. Open it in your IDE, compile, and execute it.
19
19
Now read the code in "ChemElem.cs" and "Program.cs".
20
20
21
21
The class definition "ChemElem.cs" contains:
22
22
23
23
- Three attributes,
24
24
- One constructor,
25
25
- One static method,
26
-
- One method that returns the melting point in Celsius,
26
+
- One method that returns the melting point in Celsius, and
27
27
- One `ToString` method.
28
28
29
29
The application program "Program.cs" performs one simple conversion from Kelvin to Celsius.
@@ -36,7 +36,7 @@ Do the following:
36
36
#. In "ChemElem.cs", write getters and setters for all attributes
37
37
#. In "ChemElem.cs", write a constructor that requires no arguments.
38
38
#. In "Program.cs", create a second object using the custom constructor that takes 3 arguments, then display the value of its attributes using the getters you previously defined.
39
-
#. In "Program.cs", create an object using the no-args constructor, and set its values using the setters your previously defined.
39
+
#. In "Program.cs", create an object using the no-args constructor, and set its values using the setters you previously defined.
40
40
#. In "Program.cs", display on the screen the string returned by the `ToString` method when it is called by the object you created in the previous step.
41
41
#. In "Program.cs", try calling the `FromKelvinToCelsius` method with one of your objects, for instance using `hydrogen.FromKelvinToCelsius(34)`. What happens?
42
42
#. Still in "Program.cs", try calling the `MeltingInCelsius` method with the class, for instance using `ChemElem.MeltingInCelsius();`. What happens?
@@ -48,17 +48,17 @@ We now want to significantly improve this class, by adding:
48
48
#. An attribute for the boiling point,
49
49
#. All the tools needed to display the information in Fahrenheit degrees, in addition to Celsius and Kelvin.
50
50
51
-
You may want to comment out part or all of your "Program.cs" file, before starting to change your class.
51
+
You may want to comment out part or all of your "Program.cs" file before starting to change your class.
52
52
53
53
- Add an attribute for the boiling point (in Kelvin).
54
54
- Modify the constructor, so that it takes a 4th argument, and sets its value to be the value of the boiling point attribute.
55
55
- Create a *static*`FromKelvinToFahrenheit` method, taking inspiration from the `FromKelvinToCelsius` method.
56
56
- Create a `MeltingInFahrenheit` method, that returns the melting point in Fahrenheit of the calling object. This method should use your `FromKelvinToFahrenheit` method.
57
-
- Create a `BoilingInFahrenheit` method, that return the boiling point in Fahrenheit of the calling object. This method should use your `FromKelvinToFahrenheit` method.
57
+
- Create a `BoilingInFahrenheit` method, that returns the boiling point in Fahrenheit of the calling object. This method should use your `FromKelvinToFahrenheit` method.
58
58
- Modify the `ToString` method, so that the string returned includes
59
59
- The name of the chemical element and its atomic number,
60
-
- The _melting point_ in Kelvin and in Fahrenheit,
61
-
- The _boiling point_ in Kelvin and in Fahrenheit.
60
+
- The _melting point_ in Kelvin and Fahrenheit,
61
+
- The _boiling point_ in Kelvin and Fahrenheit.
62
62
63
63
You should test all of those modifications in your "Program.cs" file as you implement them.
64
64
Use relevant data, test your program, and make sure the behavior is the expected behavior.
0 commit comments