TA Instructions
Lab 3 :The Temperature Class**
**See resources at bottom of page for additional help
______
Step One
1) Read the article from the link below. Starting from "the basics" ending at "beyond the basics"
2) Draw a class diagram for your temperature program which includes the class default constructor, attributes (instance variables) and behaviors (methods). Your class diagram should be based on the specifications below. See the class diagram for a Flight class if you are confused. See references to create UML class diagrams online for free!
a)oneinstance variable named 'degrees'
b) one temperature constructor named 'Temperature'
note: this is the default constructor and also the class name.
hint: what behavior must all temperature objects have?
c) twoaccess methods named 'getCelsius()' and 'getFahrenheit()'
hint:'getFahrenheit()' returns degrees in Fahrenheit
hint:'getCelsius()' returns degrees in Celsius
note:'getFahrenheit()' should return degrees
note:getCelsius'()' should return (5 *(degrees -32) /9)
______
______
Step Two
1.Open a text editor (i.e. word, notepad, ect.)
2.Develop a written specification (program flow) for your Temperature class based on the class diagram you created in step one. This specification will provide you with a blueprint of how to go about coding the Temperature class in java. See my specification for square class from last week's lab if you are confused.
3.Save your work
______
Step Three
1.Launch eclipse
note: make sure your saving to the z drive not my documents!
2.Create a new java project and name it 'CIS180lab3'
3.Create a new class inside the project you just created and name it 'Temperature'
note: put a check in the box which will auto-generate a main method (hint: public static void main.....)
4. At the top of your temperature class keyboard type your name, lab and class specification
note: use multi-line comment (/*)
note: use the specification you designed in step two (copy and paste)
5.Based on your specification from step two and the class diagram from step onestart to code your temperature class.
note: make sure to save frequently
note: make sure your open and closed brackets are placed correctly
note: pay close attention to capital and lowercase characters
note: make sure your code follows the correct format (i.e. location of variable, methods,
etc.)
hint: Once you have completed writing you're the Temperature class your code should contain the following: a degree variable, default constructor, getFahrenheit() access method, getCelsius() access method, and an empty main method.
______
Step Four
1. Inside your main method keyboard type the code which will create a new temperature object named "thermometer1" whose default degree value is 20.0.
2. Inside your main method keyboard type the code which will get the Fahrenheit value for the Temperature object "thermometer1" and display it back to the user
hint: see lab 2
3. Inside your main method keyboard type the code which will get the Celsius value for the Temperature object "thermometer1" and display it back to the user.
hint: see lab 2
note: your output should resemble the output below
4.Save your work
______
Step Five
1.RepeatStep Four but this time create a new temperature object named "thermometer2" whose default degree value is 98.6.
2. Once again display to the user the temperature in Fahrenheit and then in Celsius.
note: your output should resemble the output below
3.Save your work
______
______
Step Six
1.Declare comments for the following and provide details describing their purpose
1. instance variable (single line comment)
2. default constructor (declarative comment)
hint: '/**'
3. getFahrenheit() access method (declarative comment)
hint: '/**'
4. getCelsius() access method (declarative comment)
hint: '/**'
5. each line in your main method (single line comment)
2. Save your work
3. Demonstrate your work to TA
note: in order to receive credit you must demonstrate
4. Submit your work to MyCourses
note: Temperature.java + word document only!
5. Pat yourself on the back; this was a difficult lab!
______
Extra Credit
+5pt :limit the degree output to only two significant digits.
example: -6.6666667 should be -6.67
+10pt :modify your main method to prompt the user to input any degree value in Fahrenheit such that your temperature class will always display the accurate Celsius degree
______
Resources
Conversion of Temperature:
Advanced Temperature lab:
Class Diagram:
Class Diagram Generator:
note: select software design/uml then click class diagram