## Istruzioni

Congratulazioni! Hai appena scritto il tuo primo programma! Ora ti sei fatto un idea: programmare non è altro che dare semplici istruzioni al computer che le eseguirà ciecamente. La difficoltà maggiore è spiegare le cose a qualcuno tanto stupido come un computer...

Our second program will be a bit more complicated, but not much. The goal for your buggle is simply to draw a house (a box), and hide inside. Check the objective world to see exactly what this means.

For that, you will need `forward()`, `left()` and `right()`. Use your brush to mark the ground as you walk. Start marking the ground with `brushDown()`, and stop it with `brushUp()` afterward (e.g., to enter your house without marking its ground).

### What exactly is a program?

Programs are mainly suites of method calls, which are no more than a list of simple orders given to the machine. It is very similar to a recipe stating Melt the chocolate pieces, add sugar, cool the mix and serve. [!thelang] wants to have the instructions separated by semi-columns (;)[!python|scala] or by new lines[/!], and followed by parenthesis. Our little receipe would thus be written in the following way[!python|scala] (you can also add semi-columns at the end of the lines, but this is not mandatory)[/!].

    sciogliLaCioccolata()[!java|c];[/!]
    aggiungiZucchero()[!java|c];[/!]
    raffreddaLaMistura[!java|c];[/!]
    servire()[!java|c];[/!]

Do not write it all on one line only even if the computer would accept it [!python|scala](provided that you don't omit the semi-columns)[/!]. This is a really bad idea, hindering the readability. Programs must be written for people to read, and only incidentally for machines to execute, as said Harold Abelson.

There is a limited set of instructions that buggles understand, and we will eventually learn how to define new ones. For now, there is a method for each button of the interactive control panel. To achieve the same effect than the forward button (making the buggle moving one step forward), you need to write the following in the editor:

    [!java|scala|python]forward()[!java];[/!][/!][!c]stepForward();[/!]

In modo simile, per ottenere lo stesso effetto dei pulsanti [!java|scala|python]backward[/!][!c]stepBackward[/!], left e right bisogna usare rispettivamente:

    backward()[!java|c];[/!]
    left()[!java|c];[/!]
    right()[!java|c];[/!]

Il pulsante mark è un poco più particolare perché corrisponde a due metodi: il primo alza la penna ed il secondo la abbassa.

    brushUp()[!java|c];[/!]
    brushDown()[!java|c];[/!]

Il buggle offre altri metodi che sono prospettati dal menu "Help/about this world" e che saranno intodotti all'occorrenza.