CS170 Sylabus & Progress


  1. Book Chapter 1: Introduction: computer & programming



  2. Editing files

    • Introduction to file editing: click here
    • Using nedit: click here

    • Compiling and running a Java progam: click here

    • A first taste of Java programming - Classes, Objects, Methods and Statements: click here
    • Errors, errors, errors.... developing a correct Java program: click here


    • FYI only (not part of curriculum) - Working remotely from home: click here


  3. Book Chapter 2: Using Objects

    • Purpose of this unit: click here
    • Constant values, Objects, Variables and their types: click here
    • How to name variables, methods and classes: click here

    • The assignment statement:   click here

    • More details on objects and how to invoke methods on objects (important lecture):   click here

    • Representing information with objects (important lecture):   click here


    • Accessor and Mutator methods:   click here
    • Input parameters and Output values of methods:   click here
    • Printing objects:   click here
    • Importing class definitions:   click here


      Lab 2 - using an editor and writing a simple Java program: click here

      HW 1 - learning to use the Student class: click here

    • The Java API Documentation:   click here

    • Java primitive types:   click here
    • The fundamental difference between primitive type and classes - PART 1:   click here
    • The fundamental difference between primitive type and classes - PART 2:   click here
      Lab 3: learning to use BlueJ click here


  4. Book Chapter 3: Implementing Classes

    • Chapter goals:   click here
    • Highlights from Chapter 2:   click here
    • Black Boxes:   click here
    • Designing the Public Interface of a Class:   click here

    • Instance Fields:   click here
    • Implementing (=writing) the (body of) the methods:   click here
    • Testing your class:   click here
    • In-depth look at some concepts using the BankAccount class:   click here
      • What happens when you create an object (constructor invoked)
      • Difference between private and public (variable)
      • The implicit parameter of a method

    • Testing your class with BlueJ:   click here
      Lab 4: writing a method and testing with BlueJ click here

      HW 2 - implementing a Car class: click here

    • Categories of variables:   click here
      • Variables store information; information has different duration of usefulness.
      • Instance variables, local variable, parameter variables
      • How to identify the category of a variable
      • Lifetime of each category of variable
    • The implicit parameter variable of methods:   click here

    • Documenting a class:   click here
    • Summary:   click here


  5. Book Chapter 4: Fundamental Data Types

    • Chapter goals:   click here
    • Number Types (integers and floating point):   click here
      • byte, short, int, long, float, double
      • overflow in integer types
      • round off errors in float types
    • Casting (= type conversion):   click here
      • Converting between number types
      • Safe conversions: no casting necessary
      • Unsafe conversions: requires casting operation

      Lab 5: Learning about Fundamental Types and Casting: click here
    • Constants:   click here
      • Why use constants ?
      • Syntax defining constants
      • Naming constants: all caps
      • Packaging constants
      • Java's Math class
    • The increment and decrement operators:   click here
      • variable++
      • variable--
    • Arithmetic operators:   click here
      • +, -, *, /, %
      • Precedence rules:
        • priority rules for operations
        • associativity rules for operations
      • Automatic conversion rules in evaluation of arithmetic expression
    • Mathematical Functions:   click here
      • sin, cos, exp, log, etc
    • Class (or "static") methods: (important concept)   click here
      • The sin, cos, exp, log, etc, methods are examples of class or static methods
      • Class methods are called using the name of the class

    • More information of the String class:   click here
      • 2 ways to create a String object
      • String + String
      • String + Number and Number + String
      • Converting a number-String ("-123") to a number
      • Converting a number (-123) to a number-String
      • More String methods: substring()
    • Reading input from the keyboard:   click here
      • Scanner class
      • next() and nextLine(): read a String from keyboard
      • Reading integer numbers from keyboard (convert integer-string to numbers)
        Short cut: nextInt()
      • Reading floating point numbers from keyboard (convert doubletype-string to numbers)
        Short cut: nextDouble()


      Midterm 1 covers material upto this point
      Lab 6: Input and Math functions: click here


  6. Book Chapter 6: Decisions (Conditional Statements)

    • Chapter goals:   click here
    • The if   statement:   click here
      • Syntax of the if   statement
      • Meaning of the if   statement
      • Relational operators (<, <=, >, >=, ==, !=)
    • The compound statement:   click here
      • How to tell when a statement starts and ends...
      • Compound statement {...} is counted as one statement
      • Common usages of the compound statement
      • Example of a compound statement: swap by cyclic exchange
    • The if-else   statement:   click here
      • Syntax of the if-else   statement
      • Meaning of the if-else   statement
      • Example of the if-else   statement: find max of 2 numbers

      Lab 7: if statement click here

      HW 3 - implementing a better Car class: click here

    • Comparing floating point values:   click here
      • Never use == and != with float or double (round off error)
      • Use Math.abs(x - y) < EPSILON to test of x is (approximately) equal to y
    • Comparing Strings:   click here
      • s1 == s2 in String means: does s1 and s2 refer to same object
      • s1.equals(s2) in String means: does Strings s1 and s2 have the same content (same characters - case sensitive)
      • s1.equalsIgnoreCase(s2) in String means: does Strings s1 and s2 have the same content (same characters - ignoring case)
      • s1.compareTo(s2): negative value if "s1 preceeds s2", positive value if "s1 follows s2", and 0 if s1 and s2 contains the same string
    • Comparing Objects (other than Strings):   click here
      • o1 == o2 in objects means: does o1 and o2 refer to same object
      • o1.equals(o2) in objects means: does objects o1 and o2 have the same content

    • The null reference:   click here


    • Multiple Alternatives: nested if statement:   click here
      • Nested-if example: draft decision
      • Tail-nesting: making one choice among many cases.
      • Example tail-nesting: convert number grade to letter grade.

    • Advanced Example: compute the taxes owed   click here

    • Ambiguity in the IF-statement (dangling-else problem):   click here
      • Example: computing postage
      • Java is free form; it does not care how you indent your program
      • Java will try to make sense of the content of the program text - by associating keywords (here: else to if
      • If there are more than one way to associate keywords, we have an ambiguity

    • Boolean data type and methods that return a boolean type:   click here
      • Boolean constants: true, false (much like integer constants)
      • Boolean variables (much like integer variables)
      • Methods that return a boolean value (much like methods that return an integer value)
      • Very useful boolean method in Scanner class: hasNextInt() - prevent from "hanging"

    • Boolean operators:   click here
      • && (and)
      • || (or)
      • ! (not)

  7. Book Chapter 7: While Loops

    • Chapter goals:   click here
    • The while   statement:   click here
      • Syntax of the while   statement
      • Meaning of the while   statement
      • The danger of excessive power: the never-ending program (infinite loop)...
      • Example while loop 1: find all dividers of a number
      • Example while loop 2: factor a number (e.g.: 12 = 2 x 2 x 3)
      • Packaging useful methods (FindDivider and FindFactors) in your own class.

      Lab 8: while statement: click here

      HW 4 - find the Least Common Multiple: click here
    • Reading and processing input data file using the while   statement:   click here
      • Reading from in input file: the File class
      • nextInt() (always) waits until an integer number is read
      • How to read all item from a file and process them ?
      • Two techniques for reading all items in a file:
        • Sentinel (special marker that identifies the end of the file)
        • Specialized support from the programming language: boolean hasNextInt() method

    • The for   statement:   click here
      • Motivational example for the for   statement: Determine if a number n is a prime number
      • Syntax of the for   statement
      • Meaning of the for   statement
      • The prime number program re-written using for   statement
      • Examples of the for   statement: computing the factorial of n

    • Nested loops: click here
      • Similar to nesting IF-statements
      • You can nest IF, IF-ELSE, WHILE and FOR statements anyway you like (or rather: need)
      • Graphical illustration of what happens when you nest loop statements
      • Example nested loop statement: find all prime numbers between 1 and N

    • Some advanced examples of loops:   click here
      • Find a zero of an arbitrary equation
        • Uses an arbitrary enclosing interval that contains a zero
        • Improve the enclosing interval with bisection.
        • Uses a while statement to repeat the process until enclosing interval is very tiny.
      • Find the definite integral for an arbitrary function
        • Uses rectangles to approximate the definite integral (= area under the graph of the function)
        • Uses a for statement to sum the area of a large number of (tiny) rectangles.

      Lab 9: More while statement click here


      HW 5 - find Perfect Numbers: click here

    • The break and continue statements: click here
      • Syntac and effect of the break statement
      • Example break: check if a number is prime (use break to stop for-loop when number is not prime)
      • Syntac and effect of the continue statement
      • Example continue: find all number < N that are prime (use continue to skip even numbers)

    • Random Numbers and Computer Simulations:   click here
      • Motivational example: find the probability of rolling 2 dice to make the value 8 (2+6, 3+5, 4+4, 5+3, 6+2)
      • One of the most important applications of computer: Monte Carlo simulations
      • (Psuedo) Random Numbers - how to generate them in Java
      • The Random class
      • Example using Random to make a N-sided die
      • Example using the N-sided die class in a (Monte Carlo) simulation program:
        • What is the average number of rolls needed to roll a 6 with one die ?

    • A Taste of Monte Carlo Methods: Estimate Pi -   click here
      • Discusses a more complicated Monte Carlo simulation program that can compute the value of Pi (3.1415926535...)
        • Computes the area of a quarter circle by throwing darts at a square
        • Probability of a dart landing inside quarter circle = Pi/4
        • Probability of darts landing inside quarter circle is then computed by a Monte Carlo experiment.

  8. Book Chapter 8: Arrays

    • Chapter goals:   click here
    • The Array data structure (Chap 8.1):   click here
      • Organizing information: data structure
      • The array data structure
      • Syntax to define an array variable
      • Syntax to create an array
      • Accessing individual elements in an arry

    • Some Examples of Array and their use (Chap 8.1):   click here
      • The length of an array: arrayName.length
      • Using array with a loop statement: fill an array with squares
      • Array algorithm 1: find the maximum value (doubles)
      • Common error 1: array index out of bound
      • Common error 2: uninitialized array variable
      • Array of Strings (String objects)
      • Array algorithm 2: find matching words in a String array
      • Arguments passed to a Java program
      • Array of Rectangle objects
      • Array algorithm 3: find the rectangle with the largest area

    • Using array to store data (prilim to searching and sorting)   click here
      • Data structure: grouping related data together (the Item class)
      • Phone/address data structure
      • Storing data structures in arrays (the ItemDataBase class)
      • Reading information into an array (populating the data)
      • Printing information in an array

    • Searching (for a value) in an array (Chap 8.5.2):   click here
      • Searching: Find related information using a name


      Lab 10: Working with arrays click here

    • Sorting an array (Bubble sort is not in text book):   click here
      • Sorting by swapping adjacent elements: the "Bubble Sort" algorithm
      • Bubble Sort on an array of integer
      • Bubble Sort on an array of Strings
      • Bubble Sort on an array of arbitrary data structure (Phone and address)

    • Two-dimensional arrays (8.6):   click here
      • What is a two-dimensional array ?
      • Defining two-dimensional array variables.
      • Creating two-dimensional arrays.
      • Accessing (individual) elements in a two-dimensional array.

    • Using two-dimensional arrays (8.6):   click here
      • Using a nested for-loop to access (all) elements in a two-dimensional array

    • Solving similtaneous linear equations by Gaussian elimination:   click here
      • We will write a program that can solve N simultanoeus equations
      • Pre-liminary: 2 operations that maintain the equality (invariants)
      • The Gaussian Elimination method:
        1. Normalize row i
        2. Sweep other rows using row i
      • Programming the Gaussian Elimination method in Java

    • Copying Arrays: click here
      • A copy of an array is a new array that has the same content as the old array
      • The assignment operator (=) does not copy arrays - it only makes an array variable point to the (same) array
      • How copy array:
        1. Make a new array
        2. Use a for loop to copy elements from the old array to the new array

    • Increasing array size in Java: click here
      • Make a (new) bigger array
      • Use a for loop to copy elements from the old array to the new (bigger) array
      • Point to the new (bigger) array

  9. Book Chapter 9: Designing Classes - more programming language concepts

  10. Book Chapter 13: Inheritance

  11. Book Chapter 11: Interface











    Material below are OBSOLETE and will be updated....



    Hand out project 1 to reinforce UNIX & intro to Java: click here