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.

#Driver code

If you run this code, you will see that the results are the same in both cases. Examine this code and ensure that you understand it.


public class Driver {

        public static void main(String args[]) {
                //Using less modern  validation techniques
                SpotWithValidation1 spot1 = new SpotWithValidation1(10, 1000, "Older Method of Validation"); //note this description is too long
                System.out.println("Calling print on constructed spot - should be defaulted ");
                System.out.println(spot1.toString());
                System.out.println("Trying setter with invalid value (-200)");
                spot1.setX(-200);
                System.out.println("Calling print  - x value should not have changed");
                System.out.println(spot1);

                // Now use the new validation technique. We will use this form of validation during this module.
                SpotWithValidation2 spot2 = new SpotWithValidation2(10, 1000, "More Modern Method ");
                System.out.println("Calling print on constructed spot - should be defaulted ");
                System.out.println(spot2.toString());
                System.out.println("Trying setter with invalid value (-200)");
                spot2.setX(-200);
                System.out.println("Calling print  - x value should not have changed");
                System.out.println(spot2);
    }
}