Course Info

#Programming Fundamentals 1

This is an introductory Programming module and assumes no prior knowledge of programming.

In this module, we will introduce you to the Java programming language through the Processing Development Environment (PDE) and then IntelliJ.

First, we will work through non-complex problems that will introduce you to the basic constructs of programming languages i.e. Sequence, Selection and Loops. You will also learn to use variables, different data types, manipulate the data, logical operators and methods. This will be done using processing.org

Then, using IntelliJ, we will progress to more complex problems that will briefly introduce you to object-oriented programming and data structures. You will do a deeper dive into both of these areas in the semester 2 module, Programming Fundamentals 2.

Exercises

  • For each exercise listed below, create a new sketch.

  • You may need to visit the Processing website for additional information.

Exercise 1 (static drawing)

Create a display window of 400x400 with a grey background.

In the setup() method, use a for loop to draw a chessboard (for this exercise, use the line() method).

A chess board is an 8x8 grid and should look like the screen shot below:

Chess Board using line method

Exercise 2 (static drawing)

Create a new sketch and re-write the Exercise 1 code to use while loops instead of for loops.

Exercise 3 (static drawing)

Create a new sketch and re-write the Exercise 1 code so that the chess board is drawn correctly regardless of the width and height of the display window.

Chess Board on a non-square display window

Console Exercise 1

Create a new sketch and use a while loop and the println method to print hello 5 times to the console.

When you have it working using the while loop, refactor your code to use a for loop.

Console Exercise 2

Create a new sketch and use a for loop and the println method to print the numbers 1 to 10 to the console.

When you have it working using the for loop, refactor your code to use a while loop.

Console Exercise 3

Create a new sketch and use a while loop and the println method to print 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, blast off to the console.

When you have it working using the while loop, refactor your code to use a for loop.

Console Exercise 4

Create a new sketch and use a for loop and the println method to print all the even numbers between 2 and 10 to the console.

When you have it working using the for loop, refactor your code to use a while loop.