0% found this document useful (0 votes)
5 views9 pages

Coding

The document provides study notes for Grade 8 coding and robotics, focusing on computational thinking, flowcharts, pseudocode, and the Greenfoot programming environment. Key concepts include decomposition, pattern recognition, abstraction, algorithms, and important Greenfoot classes like Actor and World. It also covers variables, methods, movement methods, random numbers, edge detection, collision detection, debugging, and offers study tips for students preparing for their cycle test.

Uploaded by

amohelangfoloko
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views9 pages

Coding

The document provides study notes for Grade 8 coding and robotics, focusing on computational thinking, flowcharts, pseudocode, and the Greenfoot programming environment. Key concepts include decomposition, pattern recognition, abstraction, algorithms, and important Greenfoot classes like Actor and World. It also covers variables, methods, movement methods, random numbers, edge detection, collision detection, debugging, and offers study tips for students preparing for their cycle test.

Uploaded by

amohelangfoloko
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

GRADE 8 CODING AND ROBOTICS –

TERM 2 STUDY NOTES


Computational Thinking and Greenfoot
These notes are based on the cycle test content.

1. COMPUTATIONAL THINKING
Computational thinking is a method used to solve problems logically and step-by-step.

There are 4 important computational thinking skills:

1.1 DECOMPOSITION
Definition

Breaking a large problem into smaller, easier parts.

Example

A game can be broken into:

• Rocket
• Alien
• Bullet
• Scoreboard

Important

Large problems become easier to solve when divided into smaller tasks.

1.2 PATTERN RECOGNITION


Definition

Finding similarities or repeated ideas.

Example

• Enemies moving the same way


• Repeated code patterns
• Repeated instructions

Important

Pattern recognition helps programmers reuse solutions.

1.3 ABSTRACTION
Definition

Focusing only on important details.

Example

When planning a game:

• Focus on movement and scoring


• Ignore unnecessary details

Important

Abstraction removes information that is not needed.

1.4 ALGORITHMS
Definition

A step-by-step solution to a problem.

Example

Algorithm for making toast:

1. Put bread in toaster


2. Push toaster down
3. Wait
4. Remove toast

Important

Algorithms must be in the correct order.


2. FLOWCHARTS
Definition

A visual diagram showing the steps in a solution.

Common Flowchart Symbols


Symbol Meaning
Oval Start/End
Rectangle Process/Instruction
Diamond Decision
Arrow Direction

3. PSEUDOCODE
Definition

A simple way to plan code using normal language.

Pseudocode is NOT real Java code.

Example
START
INPUT name
DISPLAY "Welcome"
END

Common Pseudocode Commands


Command Meaning
START Begin the program
INPUT Ask for information
DISPLAY Show information
END Stop the program

4. GREENFOOT
Definition
Greenfoot is a Java programming environment used to create games and simulations.

5. IMPORTANT GREENFOOT CLASSES


5.1 Actor Class
Definition

Used to create game objects/characters.

Examples

• Rocket
• Alien
• Bullet

5.2 World Class


Definition

Creates the game screen/world.

Examples

• Space world
• Game background

5.3 Greenfoot Class


Definition

Contains useful methods for controlling the game.

Examples

• Random numbers
• Keyboard input
• Stopping the game
6. VARIABLES
Definition

Variables store information or values.

Example
int score = 10;

Variables Can Store


• Speed
• Score
• Timer values
• Positions

7. IF STATEMENTS
Definition

Used to make decisions in Java code.

Example
if([Link]("space"))
{
move(5);
}

Meaning

If the space key is pressed, the Actor moves.

8. METHODS
Definition

A method is a block of code that performs a task.

Example
public void act()
{
move(4);
}

9. THE act() METHOD


Definition

A special Greenfoot method that runs repeatedly during the game.

Important
• Runs many times per second
• Creates the game loop

10. MOVEMENT METHODS


10.1 move()
Purpose

Moves an Actor forward.

Example
move(4);

10.2 turn()
Purpose

Rotates an Actor.

Example
turn(180);

10.3 setLocation()
Purpose
Changes the position of an Actor.

Example
setLocation(getX() + 5, getY());

11. RANDOM NUMBERS


Method
[Link](60);

Purpose

Creates a random number.

Used For
• Random enemy spawning
• Random positions
• Game difficulty

12. EDGE DETECTION


Method
isAtEdge()

Purpose

Checks if an Actor touches the edge of the screen.

13. COLLISION DETECTION


Example
if(isTouching([Link]))
{
[Link]();
}
Meaning

If the Actor touches an Alien, the game stops.

14. DEBUGGING
Definition

Finding and fixing errors in code.

Common Errors
Error Example
Missing semicolon int x = 5
Missing brackets if(x == 5
Missing comma setLocation(x y);
Wrong data type int x = "5";

15. IMPORTANT TERMS TO STUDY


Term Meaning
Algorithm Step-by-step instructions
Variable Stores data
Actor Game object
World Game screen
Method Block of code
Decomposition Breaking problems into smaller parts
Abstraction Focusing on important details
Pattern Recognition Finding similarities
Pseudocode Planning code
Flowchart Visual solution

STUDY TIPS
• Learn definitions carefully
• Practice reading simple Java code
• Know what Greenfoot methods do
• Understand the difference between Actor and World
• Practice fixing small coding mistakes
• Revise pseudocode and flowcharts
• Memorise important methods like:
o move()
o turn()
o setLocation()

GOOD LUCK WITH YOUR CYCLE


TEST!
Study a little every day and practice reading the code examples carefully.

You might also like