Introduction
The Year 12 Programming assessment requires that you also include 2 advanced techniques.
You only need to pick two techniques from this list:
● modifying data stored in collections (e.g. lists, arrays, dictionaries)
● storing multidimensional data in collections
● creating methods, functions, or procedures that use parameters and/or return values
● responding to events generated by a graphical user interface (GUI)
● using non-trivial string manipulation
● using additional non-core libraries.
You only need to pick two techniques from this list:
● modifying data stored in collections (e.g. lists, arrays, dictionaries)
● storing multidimensional data in collections
● creating methods, functions, or procedures that use parameters and/or return values
● responding to events generated by a graphical user interface (GUI)
● using non-trivial string manipulation
● using additional non-core libraries.
Responding to events generated by a GUI
For those creating a video game this is the most obvious advanced technique to use.
As you have a GUI programmed with a video game then you will be able to respond to events that occur For example if touching enemy lose health. For an electronics project it becomes more difficult, you have to create a graphical user interface though an LCD screen and allow the user buttons to interact with it. |
Modifying data store in collections
In JavaScript year 11 we were forced to use an array like the following: let fruits = ["banana", "apple", "orange", "pear"] alert(fruits[2]) In year 12 it is not good enough to use the data in an array, you must manipulate the data inside. You could do this by, modifying, deleting, or adding data into the array. fruits.pop() will delete the last entry in Javascript removing "pear" fruits.splice(3,1) to remove the pear. In a video game a good place to use an array is spawning collectables, the array could be used to store the locations of different coins for example. Keep in mind that the collections is plural so you will need at least two different collections. |
Storing multidimensional data in collections
Multidimensional data is sets of data in a collection. For example storing not only the fruit name, but color and cost also.
In JavaScript it looks like storing objects in an array: const students = [ { name: "Alice", age: 20, grades: [90, 85, 88] }, { name: "Bob", age: 22, grades: [78, 82, 91] }, ]; This could be used to store different enemies and their locations. You do not need to manipulate the data in these multidimensional collections Keep in mind that the collections is plural so you will need at least two different multidimensional collections. |
Creating functions that return values or pass through parameters.
A function is a separate set of code you can call when needed.
However as an advanced technique you need two functions that receive input and return output. an example from chatGPT for calculating damage: public class CombatSystem : MonoBehaviour { // Function to calculate damage dealt public int CalculateDamage(int attackPower, int enemyDefense) { // Calculate raw damage int rawDamage = attackPower - enemyDefense; // Ensure damage is at least 1 return Mathf.Max(rawDamage, 1); } // Example of using the function in gameplay void Start() { int playerAttackPower = 25; int enemyDefense = 18; int damage = CalculateDamage(playerAttackPower, enemyDefense); Debug.Log($"Damage dealt to the enemy: {damage}"); } } |
Non-Trivial String Manipulation
Before we start we need to know the different between trivial and non-trivial.
Trivial: Single, straightforward operations (e.g., concatenation, simple slicing). Non-Trivial: Involves multiple steps, complex logic, or pattern-based manipulation. Trivial Example: alert("john" + " Doe"); Non-Trivial Example: // Non-trivial example const tweet = "Loving the #JavaScript life! #Coding #100DaysOfCode"; // Extract all hashtags const hashtags = tweet.match(/#[a-zA-Z0-9_]+/g) || []; console.log(hashtags); // Output: ["#JavaScript", "#Coding", "#100DaysOfCode"] |