o Teacher introduces the term data type,
o Examples from real-word can be discussed (e.g., integer numbers can be related to number of currently present students, decimal numbers can be related to a product price, text type can be related to instant messaging text, etc.),
o Data types are considered in the context of the Greenfoot Environment and Java programing language,
o Detailed discussion related to variable types required for the game.
o Data types are considered in the context of the Greenfoot Environment and Java programing language,
o Teacher should explain the difference between declaration and initialization of variables
o Declaration of Game-required variables.
o Additional examples can be considered. For example, if act() method is considered, variable for displaying text can be declared.
Teacher can explain operators already known from other courses (e.g., math and math arithmetic operators).These operators are considered in the context of the Greenfoot Environment and Java programing language,Teacher discusses various terms: operator, operand, operator precedence.Additional examples can be considered. Additional example may include defining local variables to retrieve and manipulate an entity's x-position and y-position, thereby changing its position by increasing the variable's values.
Teacher can explain operators already known from other courses (e.g., math and math Boolean operators). These operators are considered in the context of the Greenfoot Environment and Java programing language. The teacher discusses various terms: operator, operand, operator precedence.Additional examples may include defining local variables to check if an entity's x-position is equal to its y-position, using a boolean operator to determine if the entity is on a diagonal.
Teacher can explain operators already known from other courses (e.g., math and math relational operators),These operators are considered in the context of the Greenfoot Environment and Java programing language. Teacher discusses various terms: operator, operand, operator precedence.Additional examples may include defining local variables to check if one entity's y-position is below another's, using relational operators to determine positional relationships between entities.
The teacher can explain Boolean expressions in the context of previously presented operators. These expressions are considered in the context of the Greenfoot Environment and Java programing language. Teacher discusses operator, operand, and operator precedence in the context of boolean expressions. Additional examples may be considered. For example, boolean expressions can be used to verify that entity’s position is inside defined arena’s dimension of the game.
Teacher can explain object expression in the context of object-oriented design. These expressions are considered in the context of the Greenfoot Environment and Java programming language. The teacher discusses operator, operand, operator precedence, and class casting in the context of object expressions.Additional examples can be explored. For instance, comparing references of two object entities to check if they overlap.
Teacher should discuss Enemy's act() method. Teacher explains how to use local variables in the code, for example to use “rotation” variable. Teacher should describe difference between this.rotation and rotation. Teacher should describe getOneIntersectingObject(_cls_) method behavior. It is used and instance is stored in proper local variable (class casting is required). If there is no intersection object it returns null value. Based on the performed boolean evaluation, an appropriate acting is performed (i.e., rotating or turning). The results are discussed by the teacher and peers.
teacher should discuss constructors within the context of Class and Object OOP concepts: constructors are used to initialize concrete instances of a class. In addition, constructors are always invoked and can be defined either implicitly or explicitly. There are default constructors (which are implicitly defined) as well as parameterized and non-parameterized constructors (which are explicitly defined by a programmer). The differences between parameterized and non-parameterized constructors should also be discussed. To make this concept more relatable to students, the teacher should use real-life examples.
In this activity, a custom layout for Arena should be created. The custom layout should be provided within the constructor of the Arena class:one instance of Enemy, one instance of Orb, and at least one instance of Direction should be added. After declaring and initializing the variables, properties should be assigned by invoking the appropriate methods. Finally, these objects should be incorporated into the arena by invoking the addObject(Actor) method.
The teacher should explain that the Enemy is currently moving two cells at once, which causes issues with its movement. To address this, the speed of the Enemy can be modeled differently. The Enemy instance will now always move one cell at a time. Additionally, a new attribute called moveDelay can be defined, which will cause the Enemy instance to move only after a certain number of act() method calls have passed.
A new attribute named moveDelay of type int will be added to the Enemy class. A parameterized constructor will also be defined to initialize this attribute, with the attribute being set to the value provided by the parameter. The code in the Arena class will be adjusted accordingly.
The act() method of the Enemy class will be updated so that the Enemy moves only after the specified number of moveDelay calls of the method. Additionally, a new attribute called nextMoveCounter of type int will be introduced and initialized to 0. The act() method will be modified to call this.move(1) only when nextMoveCounter reaches 0. After the movement, nextMoveCounter will be reset to the value of moveDelay. If the Enemy instance cannot move because nextMoveCounter has not yet reached 0, nextMoveCounter will be decreased by 1.
In this session, a parameterized constructor is defined for the Direction class with a single parameter, rotation, of type int. Within the constructor body, the created instance should be rotated based on the value of this parameter. The code in the Arena class should be updated accordingly.
In this session an overloaded constructor is defined in the Direction class. A non-parameterized constructor is added, and within its body, the parameterized constructor is invoked with the argument rotation set to 0. The code in the Arena class should be updated accordingly, using the non-parameterized version of the Direction class constructor where possible.