Important Turn on Java-like syntax option in Alice, if is not on already.
Revision - Objects Our world is made up of objects These objects are computer models of real world objects They have properties (variables) that define the state of that object They have behaviours they can act out These behaviours are a list of instructions or code To manipulate our objects, we must manipulate an object’s variables or have it carry out actions.
Alice Objects All Alice objects are 3D models that are visible in your World Most Alice methods/behaviours are animations that you wish these models to carry out You can manipulate the starting positions of objects by mouse Animate characters by writing and calling methods
Alice Objects Alice objects come with many default variables and methods – default methods cannot be edited Alice provides a number of default boolean expressions - called questions Alice objects can be made up of a number of sub-objects. These can be manipulated independantly
Revision - Methods A method is a block of code (list of instructions) By default, the code is executed one line at a time We can change this using execution control structures Methods can have parameters
Alice Methods Alice methods also contain a block of code Code is written by dragging tags from one location and dropping in another We can create temporary variables for use during method execution We can define paramters for our method’s execution
Revision – IF/ELSE & boolean statements IF statements allow our computer to make a choice We use boolean statements or questions Outcome dictates which block of code executes
Alice IF statements Drag the IF tag from the top of method editing window Drag in a question Drag in code to fill in the other two outcomes
Revision – loop A loop statement loops a number of times The code is repeatadly executed
Alice loop Drag the loop tag from the top of method editing window Choose how many times you want the code to execute Drag in code to fill in the other two outcomes
Revision – While While statements loop until the testing condition is false This condition is tested prior to the next loop executing
Alice While loop Drag the while tag into the code area Drag in a question Drag in code to fill in the while loop Make sure while loop ends at some stage
Revision – Parrallel Normal execution is one line at a time By using the do together command, we can execute multiple lines at once In Java, multiple execution of code is possible – although somewhat difficultl
Dot notation If you have correctly set Java-like syntax, you will see dot notation Monkey.head is the Monkey object’s head object Monkey.head.color is the Monkey object’s head object’s color This notation allows the computer to work out who owns what