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

The object of this exercise is to refactor the Example 5.5 code to add a new parameter to the drawRedSquare method. This new parameter will set the stroke of the square.

We will also change the size of the window and the size of the square in this exercise.

The expected output will be: Expected output First, change the size of the display window to (380,340). When you run the code, you will see that the squares are not evenly distributed throughout the window. Make the changes so that the squares are laid out like the above image.

Second, amend the drawRedSquare method so that a stroke value is passed as a parameter. Set the stroke to 5.

Run your code…it should look like the above screenshot.

Exercise 2

Using the solution to Exercise 1, try produce this output: Expected outputNote that you can achieve this with just one extra line of code!