Grades for programming assessment

posted 25 Apr 2016, 23:18 by peter thompson

Grades for programming assessment

Look at the feedback document that I shared with you to see your programming assessment grades.

Mr T.


posted 12 Apr 2016, 12:01 by peter thompson

A lot of you have sent me resubmissions. This is very fast. Are you sure you have done everything? Read the feedback comments I gave you with a fine tooth comb. You can work on your resubmissions today. On Friday we have one class. We will maybe do some DHTML. What's that I hear you ask. Its using JavaScript to get and set web page content. It has been around for years and was the original use for JavaScript. Look it up.

Programming assessment documentation

posted 6 Apr 2016, 14:20 by peter thompson   [ updated 6 Apr 2016, 18:47 ]

Programming assessment documentation

I see that you have all, except Tuma, copied the documentation template. I have done a testing plan for this catch the ball game that the Y11s did as a class exercise. You will be able to use it as an example of how to do part of your documentation: Catch the ball game documentation

A good example of commenting your code is the temperature conversion program. The path to it is: S:\_DGT\DGT2\Programming\Class exercise\temperature-converter-user-input.html.
It is also attached to this post.

Handling mouse presses, an example program and notes on basic criteria

posted 31 Mar 2016, 17:30 by peter thompson   [ updated 2 Apr 2016, 23:00 ]

Code to detect which mouse button has been pressed

This is how to detect which mouse button has been pressed. The following code draws a different shape according to whether the left, middle or right button has been pressed. There are two ways to process mouse presses: in the draw and in mousePressed functions.

// In the draw function
function draw() {
    if (mouseIsPressed === true) {
        if (mouseButton === LEFT) {
        ellipse(50, 50, 300, 500);
        if (mouseButton === RIGHT) {
        rect(25, 25, 250, 250);
        if (mouseButton === CENTER) {
        triangle(23, 75, 50, 20, 78, 75);

// Using the mousePressed function
function mousePressed() {
 if (mouseButton === LEFT) {
    ellipse(50, 50, 300, 500);
 if (mouseButton === RIGHT) {
    rect(25, 25, 250, 250);
if (mouseButton === CENTER) {
    triangle(23, 75, 50, 20, 78, 75);
    // Prevent mouse press event from bubbling up and being reinterpreted by the browser
         return false;    

How to prevent the context menu appearing when right mouse button is pressed

Edit the body tag so it is like this:
<body oncontextmenu="return false;">

Screen-cast of a possible program based on the given specifications

Note: Your program does not need to be the same as the one above or the one detailed in the given specifications 

Create something simple that works, then extend it if you are know how and have time.

From the task instructions


...You can use the supplied plan as the basis for your program, adapt it to meet your needs OR come up with your own one as long as you meet the criteria in the Basic Criteria section. If you choose the last option you need to write specifications for your program....

The Basic Criteria section reads:

Ensure that in your finished program:

There is at least one indexed data structure. E.g. an array.

Is decomposed into user-defined functions and uses scoped variables, constants (variables whose values do not change), and derived values (created from some expression) effectively to increase the flexibility and robustness of the program. Scoped variables are inside functions (local) or in the main body of code (global).

Interaction between functions is minimised, functions are reused rather than their code duplicated, and the procedural structure of each function is efficient.

Comment your code and use explanatory variable and function names so that the purpose of each part of the program is clear. This includes documenting the program with comments on the purpose and behaviour of the functions. Use your comments to justify the decisions you made during the programming process.

Record your progress using a log document (Note: for log read "supplied documentation document"). In it record your testing and debugging of the program. It needs to work correctly on all inputs – expected, boundary, and invalid.

Make it rain and start assessment(?)

posted 28 Mar 2016, 15:42 by peter thompson   [ updated 29 Mar 2016, 12:16 ]

  1. We did not start the make it rain project last class so will do it today.
  2. We will then look at how to start and stop a program using the loop and noLoop functions.
  3. We will refresh our memory about how to validate user input that is meant to be numeric.
  4. If time allows we will start the assessment. You will note that there is a link to the Documentation Template, that you are to copy and complete and share with me, in the nav bar above. This and the other assessment docs can also be found on the studentread drive. The full path is: S:\_DGT\DGT2\AS91373 and US18740 Assessment Docs - 2016. You will also get a hard copy of the assessment docs.

Fix up program and make it rain program

posted 23 Mar 2016, 11:55 by peter thompson   [ updated 23 Mar 2016, 12:10 ]

Today we are going to:
  1. Fix up the following program. It is in the shared folder class S:\_DGT\DGT2\Programming\Class exercises and is called array-example-to-fix.html
  2. Work through the make it rain project on the Khanacademy, which makes a heavy use of arrays, then we are going to port the program to run in a web page using P5.js.

How to randomly get an item from an array

posted 21 Mar 2016, 11:36 by peter thompson   [ updated 23 Mar 2016, 11:53 ]

This is the way to randomly get an item from an array.
var names = ["george", "paul", "ringo", "john"];
// (random(names.length) returns a number n in the range 0 <= n < length of the array
// floor floor(random(names.length)) returns a number n in the range 0 <= n <= array length-1 (length-1 = maximum index value) of the array
var randIndex = floor(random(names.length));
var name = names[randIndex];

// Doing it all in one line
var name = names[floor(random(names.length))];

Feedback on "Using an Array" assignment

posted 19 Mar 2016, 13:36 by peter thompson   [ updated 19 Mar 2016, 13:37 ]

Feedback on "Using an Array" assignment

1) Only five of you have submitted work so far.
2) If you want to generate an array of random colours this is how to do it (you can use this approach to initialise other empty arrays e.g. circle diameters):
var numColours = 100;
// An empty array to hold semi-transparent color values
var colours = [];
for(var i = 0; i < numColours; i++) {
    // Note 4th argument to the color function sets the colour's transparency
    var aColour = color(random(255), random(255), random(255), random(50,255));
    // Add aColour to right end of colours array

Finish modifying states program

posted 13 Mar 2016, 13:10 by peter thompson

Tasks for today

  1. Finish modifying states program so it draws circles and rectangles.
  2. Look at an array example.

Submit your grades program

posted 3 Mar 2016, 11:17 by peter thompson

Submit your grades program/ Make sure you comment your code well. Look at the class exercise examples on the studentread drive, for example drawCircle-function-using-an-array.html, though there are lots of others. Remember to submit a testing plan as well. Then move onto the next functions exercise.

1-10 of 18