28.03.2014 Views

isbn9789526046266

isbn9789526046266

isbn9789526046266

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Figure 13.9: A visual program simulation exercise in UUhistle. The user is simulating the execution of<br />

a small recursive program, and has just dragged a parameter value into the topmost frame<br />

in order to create a new variable there. He is just about to name the variable using the<br />

context menu that has popped up.<br />

• To invoke a routine, click on the appropriate element (operator or function/method call) in the<br />

evaluation area.<br />

• To create a new element in memory (a frame, a function definition, etc.), click on the appropriate<br />

memory panel. This brings up a context menu in which you get to select what to create. To bring<br />

up the menu, you can click anywhere within the frame background or on the little plus in the upper<br />

right-hand corner, which is there only to hint that the frame is clickable. Exception: variables are<br />

created by dragging values, as described above.<br />

• To move to a new line, click the line or its number. (This is not always required on default settings;<br />

see below).<br />

More examples of simulation steps<br />

I will now briefly describe how to perform certain common simulation steps in UUhistle.<br />

To deal with if and while, first evaluate the condition expression. Once you have True or False<br />

in the evaluation area, click the line that execution proceeds to. On default settings, UUhistle’s VPS<br />

exercises mostly do not require the user to manually control the ‘instruction pointer’. With the exception<br />

of branching instructions such as if, UUhistle changes lines automatically as soon as the user is done<br />

with the current line. This is one of many default behaviors that can be affected by an associated setting.<br />

To evaluate a * b / 2 + (c + 1) * d, first drag and drop the value of a into the topmost expression<br />

evaluation area, then do the same for the * operator and the value of b. Evaluate the subexpression a * b<br />

by clicking on the operator; the product appears in the evaluation area, replacing the subexpression. Add<br />

the / operator, then the literal 2 from the heap. Apply the operator. Add the +. Add the value of c.<br />

203

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!