Lab: Thursday June 23


Familiariziation with DrScheme/ProfessorJ

Within the computer lap on Ryerson 4th floor

Open an xterm
Type "/home/kathyg/plt/bin/drscheme &" from the command line (without the "s)
This will start the version of DrScheme you will be using in lab

On your home computer

Be sure to download and install DrScheme, following the link on the course webpage
Run drscheme

On both

Select the Language menu
From the Langauge drop-down, select the Choose Language option
From the Choose Language drop down, select the ProfessorJ: Beginner language. This option is under Experimental Languages: ProfessorJ : Beginner.
Press the Run button on the DrScheme window.
DrScheme is now ready.


In the lower window, which is refered to as the Interactions window, enter the following

1 + 3 * 4
"Hello"
"University Dr
1 + "hi"


For the latter two, make certain to read the error message.

If the message does not explain to you why these are incorrect, ask for assistance. (Whenever you don't understand an error message in ProfessorJ please ask for an explanation).



In the upper window, which is refered to as the Definitions window, enter the following:
class Armadillo {
  int weight;
  boolean  wasRunOver;
  String name;

   Armadillo( int weight, boolean wasRunOver, String name) {
      this.weight = weight;
      this.wasRunOver = wasRunOver;
      this.name = name;
   }
}


Now press the Run button. This has added knowledge about the Armadillo to Java.

In the Interactions window enter the following:

new Armadillo( 3, false, "Steady")
new Armadillo( 15, true, "Speedy")
new Armadillo( true, "Yogi")


Make sure you understand the error message reported for the last entry

Now enter:

new Armadillo(15, true, "Speedy").weight
new Armadillo(3, false, "Steady").dead


Make sure you understand the error message of the last entry

Running Tests in DrScheme


Place your cursor in the Definitions window, at the spot where you would like to have the test appear
The cursor must not be inside of a class.

Select the Special menu. From the Special drop-down select Insert Test Case

A graphical box should appear in your Definitions window. 

In the prompt for Test within this box, enter 1 + 4

In the prompt for Should be, enter 5

Insert another test box, enter 1 + 4 * 3 in the Test prompt, and 15 in the Should be box.

Press Run, and note how Test success and Test failure are presented

Lab Problem

Had there been a lab this week, the following is the problem you would have been assigned for practice. If you feel the need for extra practice, the course staff will be happy to answer questions about this problem and assist you in assessing if it was done correctly. You do not need turn in the answers.

To complete this lab, you may need to compare Strings. Here are two operations that allow Strings to be compared, assume that 'first' and 'second' are Strings

//compare two Strings to see if they are exactly the same
first.equals(second) == true

//compare two Strings to see if they are the same, if //capitalization is ignored
first.equalsIgnoreCase(second) == true



A UFO pilot needs to check that the UFO has landed in the correct city.

Create a formal design to represent the data for this problem, and then represent the design in Java.

Follow the design recipe to solve the problem, assuming that the correct city is "Chicago"

Follow the design recipe to solve the problem again, now assuming that the correct city is given each time.

Now the pilot needs to check that the UFO landed in the correct block within the correct city, modify the design and both methods to accomodate the new requirement.