Computer Science I


August 21 Introduction to Computer Science
August 23 Guzdial and Ericson, Chapter 1
August 25 Guzdial and Ericson, Chapter 2: primitive types
August 28 Guzdial and Ericson, Chapter 2: objects and classes
August 29, 31 Lab Assignment 1
August 30 Guzdial and Ericson, Chapter 2: more about objects and classes
September 1 Guzdial and Ericson, Chapter 3: working with Worlds and Turtles
Introduction to Programming
MyTurtle.java
September 5, 7 Lab Assignment 2
MyTurtle.java
September 6 Introduction to multimedia programming
Important concepts:

Selecting a color using the text's ColorChooser class:

> import java.awt.*;
> Color color = ColorChooser.pickAColor();

 

Creating a color using java's Color class constructor (specifying red, green, and blue values):

> Color color = new Color(130,45,92);  /* red = 130, green = 45, blue = 92 */

 

Creating and showing a Picture using the text's FileChooser:

> String fileName = FileChooser.pickAFile();
> Picture p = new Picture(fileName);
> p.show();  /* display the picture */

 

Creating and playing a Sound:

> String fileName = FileChooser.pickAFile();
> Sound s = new Sound(fileName);
> s.play();  /* play the sound */

 

Arrays in Java

int[] arr;    /* arr is (null) reference to an int array */

int[10] arr;   /* arr references a 10-element int array */

int[] arr = new int[5];  /* arr references a five-element array */

int[] numbers = {1,2,3,4};   /* declaration and initialization */

Color[] colors = new Color[3];  /* colors references a 3-element array */
                                /* each element is null */
colors[0] = new Color(0,0,0);
colors[1] = Color.RED;
colors[2] = ColorChooser.pickAColor();

 

September 8 Manipulating arrays:

Using the for each statement to sum the elements of an array:

int[] arr = {10, 20, 30, 40, 50};

int sum = 0;

for (int value : arr)
{
   sum = sum + value;
}

Using a while statement to sum the elements of an array:

int[] arr = {10, 20, 30, 40, 50};

int sum = 0;

int index = 0;  /* starting subscript for an array */

while (index < arr.length)
{
   sum = sum + arr[index];
   index++;
}

 

Getting and setting the color of a pixel:

Pixel p;  /* assume p gets initialized somehow */

p.setColor(Color.RED);

Color c = p.getColor();

Getting and setting the red component of a pixel (similar methods for green and blue):

int redValue = p.getRed();

p.setRed(200);

 

Getting the pixels from a picture:

String fileName = FileChooser.pickAFile();
Picture p = new Picture(fileName);

Getting an individual pixel in row 4, column 12:

Pixel pix = p.getPixel(4, 12);

Getting all the pixels from a picture:

Pixel[] pixels = p.getPixels();

Processing all pixels with a for each statement:

for (Pixel pix : pixels)
{
    /* do something with pix */
}

Setting each pixel's red component:

for (Pixel pix : pixels)
{
    pix.setRed(200);
}

 

Repainting a picture p:

p.repaint();

Exploring a picture p:

p.explore();

 

September 11 Other Java looping statements

while statement examples:

int [] arr;

/* assume arr is initialized somehow ... */

int sum = 0;
int index = 0;

/* sum the elements of arr */
while (index < arr.length)
{
   sum = sum + arr[index];
   index++;
}

/* sum the odd-numbered elements (1, 3, 5, ...) of arr */

int sum = 0;
int index = 0;

while (index < arr.length)
{
   sum += arr[index];
   index = index + 2;
}

 

for statement examples:

int [] arr;

/* assume arr is initialized somehow ... */

int sum = 0;

/* sum the elements of arr */
for (int index = 0; index < arr.length; index++)
{
   sum = sum + arr[index];
}

/* sum the odd-numbered elements (1, 3, 5, ...) of arr */

int sum = 0;

for (int index = 0; index < arr.length; index+=2)
{
   sum = sum + arr[index];
}

Reversing the elements of an array

Reversing the pixels in a Picture

September 12, 14 Lab Assignment 3
MyPicture.java
caterpillar.jpg
September 13 Messing around with pixels
Reversing the pixels in a picture revealed!
Flipping a picture vertically     pdf
September 15 Lightening and darkening a picture
Nested loops
Nested while loops
Nested for loops
Flipping a picture horizontally
Changing a portion of a picture     pdf

Exam 1 will be given on Friday, September 22

September 18 Review of material for exam 1 (chapters 1 - 4)    htm
Practice Exam   htm
September 19, 21 Lab Assignment 4
MyPicture.java
MyTurtle.java
caterpillar.jpg
September 20 Java conditional statements    pdf
Getting started with GUI    pdf
Java Gui Examples   zip
September 22 Exam 1
Exam 1 Solution 
htm
September 25 Layout Managers   pdf
September 26, 28 Lab Assignment 5

LAB 5 POSTPONED UNTIL NEXT WEEK!!!

September 27 More about Swing   pdf
TextFieldDemo.java
GUI Guidelines   pdf
September 29 DeterminantGui2.java
October 2 Programming Assignment 1    htm
Rotating a picture   htm
October 3, 5 Lab Assignment 5
October 4 Introduction to GUI using JOptionPane      ppt
FtoCGUI.java
Scaling a Picture    pdf
October 6 Conditionally modifying pixels using if statements    pdf
October 9 A class for complex numbers    pdf   Complex.java     TestComplex.java
Prelude to Lab 6   pdf
October 10, 12 Lab Assignment 6     htm
QuadraticException.java
QuadraticSolution.java
October 11 Working with text files in Java    pdf
ReadFile.java   
ReadFileTryCatch.java
October 13 Programming Assignment 1 is due today
Exception handling    pdf
ExceptionHandlerDemo.java
October 16 Simple drawing using the Java Graphics class   pdf
October 17, 19 Lab Assignment 7   htm
QuadraticException.java
QuadraticSolution.java
QuadraticEquation.java
Complex.java
Lab7.java
October 18 Using the mouse in Java applications   pdf
MouseDemo.java
MouseDemo2.java
October 20 Programming Assignment 2   htm
Exam 2 review topics   htm
Exam 2 will be given on Wednesday, October 25
October 23 Exam and programming assignment workshop
October 22, 24 Lab Assignment 8  htm
PowerBall.java
A little application with an array search:  ArrayStuff.java
October 25

Exam 2
Exam 2 solution  
pdf

October 27 Solving the 8 puzzle    pdf   ppt
October 30 Using Stack, BufferedImage, and other stuff   pdf
PictureViewer.java
MosaicPicture.java
Oct 31, Nov 2 Lab Assignment 9   htm
3.bmp
Lab9.java
November 1 Using Graphics2D   pdf
November 3 Programming Assignment 2 Development Workshop
November 6 Programming Assignment 2 is due today
Designing and implementing classes
November 8 Using StringTokenizer and Stack to evaluate postfix expressions   pdf
November 10 Programming Assignment 3   htm
November 13 An introduction to JMenu    pdf
MenuDemo.java
November 14, 16 Lab Assignment 10 (on paper in E210!)
November 15 Introduction to sorting and searching   pdf
November 17 Binary search   pdf
November 27 Just for fun:  Java applets   pdf
Prime.java      Prime.htm
November 28, 30 Lab will not meet this week.  Use your lab time to work on Programming Assignment 3.
November 29 Review for Exam 3
Programming Assignment 3  Q & A
December 1 Exam 3
December 4 Program 3 is due via email by 3:00 pm--no late assignments accepted!
December 6 Creating classes   pdf
Student.java    Student.html
Ethics Survey
December 8 Computer Science Advisory Board Meeting (brief class meeting to return programming assignments and discuss final exam)
December 11 Final Exam  10:00 - 11:50