Before you get started on the "real" work of this lab, there are a few preliminary steps to take care of. If necessary, your lab instructor will help you through these.
After you've registered, verify that you can log in. (Click on the "Log in" link and then, on the page that appears, enter your login ID and password in the two text boxes (login ID on the left, password on the right).) Note that your login ID is not your Royal Number but rather the prefix of your U of Scranton e-mail address up to but not including the @ symbol. Thus, for example, if your name were Sarah Rumplestiltskin, your login ID might be sarah.rumplestiltskin.
Having registered for CMPS 144L, do the same for CMPS 144, the lecture part of the course. To do that, first go to the CMPS 144 course web page, click on "Student File Submission System" and then on the "Register" link. As before, enter your Royal Number. At this point, you should get the message Prior registration bound to this context!, which means that you have successfully registered for both the lab and lecture parts of the course and your login ID and password are the same for both.
There are a variety of "integrated development environments" (IDEs) intended to provide support to a programmer (to make the task of programming as easy as possible). The one that we encourage students to use in the first couple of CMPS courses is jGrasp. If your computer doesn't already have it (e.g. from when you took CMPS 134), you are encouraged to install it. Use the link in the previous sentence to get to the jGrasp website.
Enter an initial temperature reading, which should be a number optionally followed by C or F: -5C Calling Temperature(-5.000000,true) toString() yields -5.0C toString(true) yields -5.0C toString(false) yields 23.0F Enter command (H for help): C +18F Calling changeBy(18.000000,false) toString() yields 5.0C toString(true) yields 5.0C toString(false) yields 41.0F Enter command (H for help): S 45 Calling setTo(45.000000) toString() yields 45.0C toString(true) yields 45.0C toString(false) yields 113.0F Enter command (H for help): D 68F Computing difference between 45.0C (113.0F) and 20.0C (68.0F) difference(20.0C, true) yields 25.000000 difference(20.0C, false) yields 45.000000 difference(20.0C) yields 25.000000 toString() yields 45.0C toString(true) yields 45.0C toString(false) yields 113.0F Enter command (H for help): Q Goodbye. |
To test your work, you are expected to make use of jGrasp's Workbench feature and/or the TemperatureTester application. An example of a user/program dialog with that application is shown to the right, with input entered by the user shown in boldface.
The application begins by inviting the user to enter an initial temperature value, which is specified by a numeral optionally followed by either C or F (to indicate Celsius or Fahrenheit, respectively). (The default is Celsius.)
Thereafter, the user is expected to enter commands, each of which indicates either that the temperature is to be
Not surprisingly, these commands are translated by the application into calls to methods in the Temperature class, namely changeBy(), setTo, and difference().
When you are confident that you have completed the class so that each of its methods fulfills its specification, use the Student File Submission System to submit the source code file into the "Lab #1" folder. (See the link to it near the top of the CMPS 144L course web page.) Your lab instructor will assist you, if necessary.
One of your goals should be to complete the class without introducing any assignments to the instance variable. That is, the only method that should include a statement of the form celsiusDeg = X (where X is some expression) is the version of setTo() that was provided to you.
Another goal should be to re-use code wherever possible, rather than repeating code. For example, if two methods have similar purposes but one of them is specific to a particular temperature scale (e.g., Celsius) and the other method handles either scale, one of those methods should call the other one. (For a good example of this, see how the argument-less version of toString() calls the one-argument version. A similar relationship holds between the two versions of setTo().)
A third goal is to make use of the provided private methods. Calls to private methods would be appropriate in the degreesFahrenheit() method and at least one of the changeBy() methods.