UNCW Home UNCW HomeBreaking News! Click here for details.
 CSC 121 - Introduction to Computer Science I 

LECTURE   Week Number

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

       Week 1 Aug 19 First day of classes

  1. In class: 1.1.1 p.6  Hello World
    OS X / Linux / Windows
    % javac HelloWorld.java
    % java  HelloWorld

    where % represents the command line prompt in the current directory
    Exit competency:  (hw demo by end of class or before beginning of next class)
                    Ex. 1.1.5 p. 13 modify UseArgument
      Objectives:
    1. Using text editor
    2. verify installation of JDK
    3. competency with javac and java commands
    4. work with command line arguments
    5. introduce array notation
    6. vocabulary

      Week 2 Aug 24

  2. In class: 1.2.1 p.20 String concatenation example
                    1.2.2 p. 22 Integer multiplication and division  (develop from command line reverse orders and signs)

    Exit competency:  (hw demo by end of class or before beginning of next class)
                    1.2.1 p. 20 extended to ruler7 -how many characters are printed?

      Objectives:
    1. Identifiers, Literals, and Variables p. 15
    2. Statements: declarations, assignments, and initialization p. 17
    3. Tracing changes in variable values p. 17
    4. data types: String, int pp 19, 21
    5. source files, class files
    6. vocabulary
  3. In class:  1.2.3 p.20 Quadratic formula 
                    1.2.4 p.27 LeapYear
    Exit competency:  (hw demo by end of class or before beginning of next class)
                   1)  Accept 3 command line arguments and report whether they are in order, and
                   2)  Similar to Ex. 1.2.33. How far to the hurricane (ilm: 34.26 Latitude 77.84 Longitude?)
      Objectives:
    1. Boolean, numeric types (double, long) pp 25, 32
    2. Comparisons
    3. Math class methods, API, p. 29
    4. Anatomy of a method signature p. 30
    5. Type conversion pp 31, 32
    6. vocabulary

      Week 3 Aug 31

  4. In class: conditionals and loops, 1.3.1  p 49 Flipping a fair coin, 1.3.2 p. 51 Your first while loop, then extend 1.3.1 to count number of times heads/tails come up in a loop, extend to count outcomes for rolls of a six sided die with a variable for each outcome. Accumulating a sum p. 57 examples (all)
    Exit competency:  (hw demo by end of class or before beginning of next class)
                    1) Ex. 1.3.16 p. 79, and
                    2) Program 1.3.5 p 61 Harmonic numbers -extend to calculate the sum two ways, [1, N] and [N, 1] to determine order of magnitude of N for the sum to diverge in the last digit, last two digits, last 4 digits. What might be the cause of these discrepancies?
      Objectives:
    1. flow of control
    2. while loops
    3. for loops
    4. conditional operator:  int min = (x < y) ? a : b;
    5. algorithms
    6. vocabulary
  5. In class: nested loops, 1.3.7 p 64 Converting to binary, 1.3.9 Factoring Integers, FairDie.java

    Exit competency: (Out of class program assignment due 1 class after next: 9/10 -001, 9/14 -003) Create a simple plotter (x-axis runs vertically, y -axis runs horizontally) using command line arguments for a (left end point), b (right end point), and n (number of sub-intervals of [a, b].) Plot.pdf Steps:

    1. compute maximum and minimum values of the function on [a, b].
    2. compute scaling factor sf. For example, does the following accomplish all we need?
      sf = 1/(max - min).
    3. construct for each point in the interval the required number of spaces (one for each column) preceding the plot (an *)
      #cols = sf ( f(a +idx) - min ).
        Points breakdown
      • 0 - doesn't compile
      • 20 - Input and output a, b, & n
      • 40 - Calculate and print dx
      • 60 - Find and print the max & min on [a, b]
      • 80 - Find and print the scale factor
      • 100 - Plot the function x3 on [a,b] in one program and
                   e-(x*x)sin(6π x) on [-1, 1] in another. You will be required to demonstrate your program using a test function provided in class on the date delivery is due.
      • 110 - Plot with x-axis running horizontally and y-axis running vertically
     
      Objectives:
    1. nested for loops
    2. nested mixed loops
    3. algorithms
    4. debugging

      Week 4 Sep 7- Monday Labor Day State Holiday no classes

  6. Lab day section 001
  7. In classFairDie.java variables in context of args[] develop an array f. Using this transformation, 
    1. We can have as many faces as desired using a runtime argument
    2. The code is much quicker to implement
    3. Shorter code is easier to debug
    4. Recall tmp = (int)(Math.random()*6 + 1)
      1. How can this be adapted to n faces?
      2. How can tmp be used to count the outcomes?
       
    5. Initialization is simplified
    6. Output of results is simplified
    7. Typical array processing code (for arrays of N double values)

    Exit competency:  (hw demo by end of class or before beginning of next class) SpotSummer, write a program that will simulate 100 rolls of a set of five standard six-sided dice, store and display the outcome of each die and the sum for the roll. Find and report the average sum over the 100 rolls. Sample output
                   
      Objectives:
    1. arrays
    2. zero-based indexing
    3. array length
    4. memory representation
    5. bounds checking
    6. setting array values (initialization) at compile time
    7. setting array values at run time

      Week 5 Sep 14

  8. In class
    Exit competency:  (hw demo by end of class or before beginning of next class) SpotSummer extended to next class
                    
      Objectives:
    1. exchanging values in an array
    2. shuffling an array
    3. use of variables to hold constant values
    4. two-dimensional arrays
    5. transpose a square array in-place
    6. transpose a rectangular array using a new array
  9. In class:  Algoritharium
    Exit competency:  (hw demo by end of class or before beginning of next class) MyImagealgorithms.java based on the quick tutorial in Algoritharium, complete exercises 1-7. For #7, use a double array to hold the source image's colors. For each color in the array get the red, green and blue representations as int using the Color object's getRed, getBlue and getGreen methods. Find the average of these three values and store this average in an int named gray. Replace the original Color in the array with a new Color -the object returned from new Color(gray, gray, gray). Finally set the target's pixel colors using setPixelColors. The code written for step 7 depends on two versions of the same ImageViewer -select duplicate from the ImageViewer file menu to create a second ImageViewer. Note: Step 7 in the tutorial has been modified to initialize the second ImageViewer with the source image prior to performing your image manipulations. Larger images may cause an out of memory error the solution to which is given in the Algoritharium link. Be sure to download algoritharium.jar file again to get the latest version if you had previously downloaded the file.

    Using the text's standard libraries and external jar files in your programs.

    Classpath. To access it, put stdlib.jar in the same directory as the program you are writing. Then, compile and execute as follows. Similarly for algoritharium.jar.

    OS X / Linux
    ------------
    % javac -cp .:stdlib.jar MyProgram.java
    % java  -cp .:stdlib.jar MyProgram
    
    Windows
    ------------
    % javac -cp .;stdlib.jar MyProgram.java
    % java  -cp .;stdlib.jar MyProgram
    
    or
    for
    Algoritharium
    files
    OS X / Linux
    ------------
    % javac -cp .:algoritharium.jar MyProgram.java
    % java  -jar algoritharium.jar
    
    Windows
    ------------
    % javac -cp .;algoritharium.jar MyProgram.java
    % java  -jar algoritharium.jar
    

    The -cp flag sets the classpath. The . tells Java to look in the current directory for .java and .class files (such as MyProgram.java and MyProgram.class). The stdlib.jar tells Java to also look in the .jar file. On OS X, the : separates directories in the classpath; on Windows the ; separates directories.

    My program runs out of memory, but my system should have more than enough. What's going on?  The java heap is the area of RAM reserved for use by the Java virtual machine. You can specifically ask for more (assuming your system has enough) with the following command:
    % java -Xmx300m -Xms300m -jar algoritharium.jar

    In this case, we are asking for 300 MB of memory (note no space between the switch and size and correct units are none for bytes,  k for kilobytes,  m for megabytes, M for megabytes, or g for gigabytes.) The -Xmx sets the maximum heap size, the -Xms flag sets the initial heap size. The operating system determines whether physical ram or paging will be used to achieve the requested memory.

               

      Objectives:
    1. Modify a single pixel in an image
    2. Modifiy several adjacent pixels in one row of the image
    3. Use iteration to modify several adjacent pixels in one row of the image
    4. Make the entire image red
    5. Red/green checkerboard
    6. Implement a red filter
    7. Image algorithm involving multiple images -make the second image a grayscale version of the first.
    8. Command line switch to include a jar file in the classPath for the java/javac commands

      Week 6 Sep 21

  10. In class:  Algoritharium Basic Image Filter Design. Three quizzes in Blackboard -be sure to log in to your account prior to class: User ID is your UNCW email without the @uncw.edu, password is your six digit SeaNet password. Take the practice exam under Assessments to see how it works.
    Exit competency:  (Out of class program assignment 2 due: 10/14 -003, 10/15 -001) Add a Sobel edge detection feature to your ImageAlgorithms class. First carefully read the discussion on the gradient edge detection technique in this Sobel edge detection tutorial, then make a flow chart for your program. Only after understanding the problem at hand and flow charting it should you begin to code. Your algorithm should demonstrate understanding of these objectives.
    Objectives:
    1. Flow Charting, input/process/output
    2. Grayscale an image working with the double array data structure.
    3. Apply a mask to a two dimensional array
    4. Select a threshold for edge detection (trial and error works well here, record your results)
    5. Half tone the image with white at the edges and black elsewhere
    6. Commenting your code
       
  11. First Interim Exam -no notes All assignments due prior to the interim must be completed and graded before the interim.

            Week 7 Sep 28

  12. Lab day - Use Eclipse if you prefer. Using Eclipse -shows how to download and incorporate an external jar file into your project.
     
  13. In class:   Complete the Using Eclipse tutorial. In class discussion of Sobel edge detection algorithm
    Objectives:
    1. Flowchart
    2. Describe your algorithm in words using comment blocks
    3. Describe the results of your threshold testing including intermediate results using comment blocks
    4. Demonstrate your algorithm on several images

    Week 8 Oct 5  No classes M/T (Last day to withdraw with a W is Thursday the 8th)

  14. Fall Break
  15. In class:   2.1 Modularize programs using static methods.  Chapter 2 uses stdlib extensively. The easiest way to use  these is with stdlibSourcecode.zip -just unzip this folder and place the class definitions desired into your working folder. An alternative technique is to follow the guidelines from Week 5 and import stdlib package or if using Eclipse follow step 5.
    Exit competency:  (hw demo by end of class or before beginning of next class)
    Two parts:
    1. How many times does the Phi(z)for loop in program 2.1.2 run before exiting? Modify the program's function Phi(z) (standard Gaussian cdf using Taylor approximation) to print z and the last value of i that caused the for loop test condition to fail. Cleverly test several (at least 64) values in the range [-8, 8] from a small test client you write. In your test client, also print each return value from Phi(). To avoid a cluttered screen, pipe your output to a text file using:
      % java Gaussian > out.txt
    2. Unzip ch2.zip, play a couple of songs from the command line, then write PlayThatTuneWell incorporating the harmonics described in Superposition on pp 203-205. Replay, to test the improvements.

    Objectives:

    1. Using and defining static methods
    2. Anatomy of a static method: argument type, return type, method body, scope
    3. Implementing mathematical functions - the Gaussian (normal) distribution function.
      For example, we might wish to have a simple program SATmyYear.java that takes a value x from the command line and prints (Φ(x) - 1019)/209, so that we do not need to type in the mean and standard deviation each time we want to know the percentage scoring less than a given value for a certain year. Moreover, any other class in that directory can make use of the methods defined in Gaussian, by calling Gaussian.phi() or Gaussian.Phi().
    4. Arrays as arguments and as return types. Ex. Superposition of sound waves
    5. vocabulary

      Note: Algoritharium has been updated.


      Week 9 Oct 12

  16. In class:  2.2 Libraries and clients
    Exit competency:  (Out of class program assignment 3 due: 10/21 -003, 10/22 -001) P 312 Creative Exercise 2.4.20 Game of life. Implement a class Life that simulates Conway's game of life. Sample output, using Standard Draw from the stdlib.
                    
  17. In class:   3.1 Data types
    Exit competency:  In class demo of  your Sobel edge detection algorithm
                    
      Objectives:
    1. Flowchart
    2. Describe your algorithm in words using comment blocks
    3. Describe the results of your threshold testing including intermediate results using comment blocks
    4. Demonstrate your algorithm on several images

      Week 10 Oct 19

  18. In class:   3.2 Data types  Thirty minute Practical 1 (be prepared to do write a short program using single arrays.)
     
  19. In class:   3.2 Creating Data Types continued
    Exit competency:  Demo Project 3 "The Game of Life."                  
      Objectives:

    1. Week 11 Oct 26

  20. In class:  Quiz 4, 3.3 Data types, Fifteen minute Practical 1a (be prepared to do write a short program using double arrays.)
    Exit competency: Write an instantiable class named Complex with methods abs, plus, times and toString. Use this class with Mandelbrot.java  -note the code in program 3.2.7 in our text has an error as it allows Color constructor arguments outside the range [0, 255]. Experiment with the command line arguments that specify the center and size of a region of interest to find plots of interest. Mandelbrot Set video Sample out:  %java Mandelbrot .1045 -.637 .01                
      Objectives:
      Note: The easiest way to use  these is with stdlibSourcecode.zip -just unzip this folder and place the class definitions desired into your working folder. An alternative technique is to follow the guidelines from Week 5 and import stdlib package or if using Eclipse follow step 5.
  21. In class:   Creating Data Types;  Identifying rectangles in an image. Automaton: Skiing Robot Races Down Slope (Video)
    Exit competency:  (hw demo by end of class or before beginning of next class) Download the latest version of algoritharium.jar. Add a zoomDemo** to the Algoritharium for Mandelbrot
    	   **Save the zoomDemo zip file and import to Eclipse using 
    	   File/import/General/Existing Projects into Workspace 
             -Select archive file and browse to find the saved zip file, click to open. 
    	   Alternatively, without using Eclipse, extract and place a current 
              copy of algoritharium.jar in the src folder and compile/execute from the command line. 	

    Week 12 Nov 2

  22. In class:  3.3 Designing Data Types
    Exit competency:  ((Out of class program assignment 4 due: 11/11 -003, 11/12 -001) Given an image containing several rectangles of the same size with the closer ones appearing larger. Create a five pixel green border inside the largest, red border inside the next largest and blue borders inside all smaller rectangles. Print to System.out the location, width and height of all the rectangles in order from largest to smallest. Use this rectangle as your test case.
    1. Document your code annotating the purpose of each method.
    2. Use a separate data type which you define named Rectangle with at least the following:
      1. Private instance variables x, y, width, height.
      2. A constructor that takes parameters x, y, width, and height.
      3. A compareTo(Object o) method that returns a negative integer if the area of this rectangle is greater than the area of the argument rectangle, a positive integer if the area of this rectangle is less than the area of the argument rectangle. If the areas are the same, then if this rectangle has a larger y value return a negative integer, if the argument rectangle has a larger y value return a positive integer, otherwise return 0. In this way the natural ordering will be such that closest (largest) comes before furthest.
      4. A toString() method
      5. A getArea() method
      6. Both getX() and a getY() methods.
      7. A contains(Point p) method or equivalently contains(int x, int y) that returns true  if this point would lie inside the rectangle on the image.
  23. In class:   Designing Data Types -Blue Screen Photos in class
      Objectives:

    1. Week 13 Nov 9

  24. Second Interim Exam All assignments due prior to the interim must be completed and graded before the interim.
  25. In class:   Extending the Picture class.
    Exit competency:  (hw demo by end of class or before beginning of next class) Complete the GUI modifications and image analyses per the instructions found in Picture.java
                    
      Objectives:
    1. Add Menu Items to an instantiable class to open .jpg, or .png images
    2. Shift bits and apply a mask to extract r, g, and b values embedded inside an int representing a pixel.
    3. Add functionality to calculate the average of the red, blue, and green pixel intensities column by column
    4. Add functionality to shift an image

      Week 14 Nov 16

  26. In class: 
    Exit competency:  (Out of class program assignment 5 due: 11/30 -003, 11/31 -001) Write an instantiable class definition that merges two image files where one of the files has an identifiable background that can be replaced by pixels from the other image. The goal is to have a crisp merge with little to no signs of the original background. Include supporting methods as needed that allow manipulation of the "blue screen" image to make it compatible with the image used to create the composite. Sample supporting methods: Be creative, design your own set of supporting methods. Images 1 and 2 have been merged here to make a third: Image1, Image2, Image3 Student results: yuli1, yuli2
     
  27. In class: Practice Practical 2, Demo Projects and Labs  
     

    1. Week 15 Nov 23 No classes W/R/F Thanksgiving State Holiday

  28. In class:  Practical 2 -write an instantiable class definition with instance variables, constructor(s), and practical methods to be specified in class. Include a simple test client to verify the functionality of the data type.
     
  29. In class:  
                    

    1. Week 16 Nov 30-Wed Dec 2 (Last day of classes)

  30. In class: 
                     
  31. In class: