Presentation is loading. Please wait.

Presentation is loading. Please wait.

Bishopston Comprehensive School

Similar presentations


Presentation on theme: "Bishopston Comprehensive School"— Presentation transcript:

1 Bishopston Comprehensive School
Unit 2: Bishopston Comprehensive School

2 What is required? For the online test you are required to complete 3 tasks. HTML (6) Algorithm (9) Greenfoot (15) The Greenfoot tasks follow a pattern and asks almost the same thing every year but with different scenarios. Fantastic opportunity to get some high marks on this section so practise as much as you can. We are going to complete the 2016 controlled assessment task now.

3 Controlled assessment Task 2016 (15 marks)
(a) Populate the world with a cat, a mouse hole and at least two mouse objects. (b) Edit the mouse so that mice turn and move randomly. (c) Edit the program code to make the cat move in the direction of the arrow keys when pressed. (d) Edit the cat so that it “catches” a mouse when they collide (removes the mouse from the world). (e) Add a sound which will play every time the cat “catches” a mouse. (f) Add a counter and edit the cat code so that the counter displays how many mice have been caught. (g) Edit the mouse so that it “escapes” from the world if it collides with the mouse hole (removes the mouse from the world). (h) Edit the mouse code and the counter code if necessary so that the counter loses a point (1 point is deducted) if the mouse “escapes”. (i) Save your completed world as FinalWJECChase

4 Objects and classes Class: Llama Name: Leroy Age: 5
Leroy the Llama Class Class: Llama Name: Leroy Age: 5 BreedName: Frizzy White HairRating: 10

5 Brackets in Java ( ) round brackets:
Known in the USA as “parentheses”, in the UK these are known as standard brackets. They are used in mathematical expressions, surrounding the parameter lists for method calls. [ ] square brackets: In Java these are used for arrays. { } curly brackets: These are called “braces” or “squiggly brackets”. In Java, these are used to surround blocks of code such as methods of class content.

6 (a) Populate the world with a cat, a mouse hole and at least two mouse objects.
Create a new subclass of ‘Actor’ by right clicking on it and choosing ‘new subclass’. Name the subclass e.g. cat, and choose an image from the categories. If there isn’t anything suitable then choose ‘import from file’ after saving one from the internet. Continue to add other actors in this way. If you are required to add a background. (Hasn’t been a task since the GCSE started) Choose subclass of world instead of Actor. To add the actor to your world, right click and choose new ‘cat()’, mouse(), e.t.c. and place it. Once your actors are placed right click the world and choose ‘save the world’ to stop them from disappearing.

7 (b) Edit the mouse so that mice turn and move randomly.
To program a mouse to move randomly double click on it in the actors list. Enter the following code: Make sure you open and close the ‘{ }’ Run the code by pressing the ‘run’ button. What is going on in this piece of code?

8 (c) Edit the program code to make the cat move in the direction of the arrow keys when pressed.
Double click the cat in the actors list to open the programming page. Enter the following: Now up is done, can you program the cat for the other 3 directions? Down, left and right.

9 Answer

10 Greenfoot library REMEMBER: If you forget any of these commands/functions you can always use the Greenfoot Class Documentation. In Greenfoot click ‘help’ – ‘Greenfoot Class Library’ You can then view all the different functions available in Greenfoot relating to the actors, worlds, sounds, images, e.t.c.

11 Example of Greenfoot Library
The next task is to remove the mice once the cat touches it. By using the documentation and clicking on actor we can find what we need.

12 (d) Edit the cat so that it “catches” a mouse when they collide (removes the mouse from the world).
As you can see by using the same layout as the documentation suggests you can get the program to do as you want by replacing the template words. E.g. ‘class’ for the name of the class in this case ‘Mouse’.

13 (e) Add a sound which will play every time the cat “catches” a mouse.
As this is linked with the ‘isTouching’ function we can just add the action into that section. Before we can add the sound we need to download and save one. These will be provided in the actual task. Enter the file name and type e.g. slurp.wav

14 (f) Add a counter and edit the cat code so that the counter displays how many mice have been caught.
For this we need to add a new ‘Counter’ class. Edit – Import Class – Counter – Import Right click the ‘Counter’ actor, choose ‘new counter’ and place it on the screen and save the world. Firstly we want the counter to increase when the cat touches the mouse. We already have the ‘isTouching’ from before so we simply add the following line.

15 Add counter into the Cat actor as we want it attached to the cat
(f) Add a counter and edit the cat code so that the counter displays how many mice have been caught. We want the counter to appear as soon as the program starts but we also need it to reset each time so double click on ‘MyWorld’ class. Add these lines Add counter into the Cat actor as we want it attached to the cat

16 (f) Add a counter and edit the cat code so that the counter displays how many mice have been caught.
Finally to allow the score to increase we need to save it as a variable. We add this section of code in the cat actor. Double click on the ‘cat’ actor.

17 (g) Edit the mouse so that it “escapes” from the world if it collides with the mouse hole (removes the mouse from the world). Use previous example of the cat touching the mouse to remove it to complete this step. Remember this is the code what would we need to change?

18 (h) Edit the mouse code and the counter code if necessary so that the counter loses a point (1 point is deducted) if the mouse “escapes”. Where have we done something like this before? Use and add to this code so that if the mouse touches a mouse hole the points are reduced by one.

19 (i) Save your completed world as FinalWJECChase
Once finished click – Scenario / Save as / call the file whatever the exam board asks. In this instance FinalWJECChase

20 Further tasks – 2014 exam Open the WJECCrabs scenario in Greenfoot.
(b) Populate the world with a crab and some wombats. (c) Edit the wombat so that it turns and moves randomly. (d) Edit the program code to make the crab move in the direction of the arrow keys when pressed. (e) Edit the crab so that it “eats” a wombat (removes the wombat from the world) if they collide. (f) Add a sound which will play every time a crab “eats” a wombat. (g) Add a counter and edit the crab’s code so that the counter displays how many wombats the crab has “eaten”. (h) Save your completed world as FinalWJECCrabs

21 Further tasks – 2015 exam Open the WJECIceBreaker scenario in Greenfoot. (b) Populate the world with a Ship (Icebreaker) and some Icebergs. (c) Edit the Icebergs so that they turn and move randomly. (d) Edit the program code to make the Ship move in the direction of the arrow keys when pressed. (e) Edit the Ship so that it “breaks” an Iceberg when they collide (removes the Iceberg from the world). (f) Add a sound which will play every time the Ship collides with an Iceberg. (g) Add a counter and edit the Ship’s code so that the counter displays how many Icebergs have been broken (removed from the world). (h) Save your completed world as FinaIIceBreaker


Download ppt "Bishopston Comprehensive School"

Similar presentations


Ads by Google