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.

Conditional Example 3.1

In this step, we will implement an example from your lecture.

If the x coordinate of the mouse pointer is on the:

  • left half of the display window, draw a rectangle on the left hand side.

  • right half of the display window, draw a rectangle on the right hand side.

Conditional Example 3.1

Create a new Processing sketch in your workspace and call it Example_3_1.

Enter the following code into your sketchbook (avoid the temptation to copy and paste it…you learn more by writing the code out):

void setup() {
    size(100, 100);
    noStroke();
    fill(0);
}

void draw() {
    background(204);
    if (mouseX < 50) 
    {
       rect(0, 0, 50, 100); 
    } 
    else 
    {
       rect(50, 0, 50, 100); 
    }
}
  • Run your code. Does it work as you would expect?