Spring Semester 2003

A201 Web-Based Bulletin Board


Thu Jun 5
Here's the new ClassPak (final version for Summer II).

Tue May 6
Here's the final exam.

Sun May 4
Please go in QuizSite and tell me what kind of exam you want to take.

There are two options:

  1. a (default) option: multiple-choice, and
  2. an essay type of exam (a problem from chapters 1-7)

For the second option:

Thu-Sat May 1-3
Grades updated. Still more to come.

Please check your grades and report what's missing.

Wed Apr 30
Please don't forget to submit your A201 Course and Instructor Evaluations!

Thanks a lot for your feedback!

Here's a program very much like Homework Five...

Tue Apr 29
Grades updated, again.

Lab Twelve is asking you to go through all QuizSite exercises by May 4.

In lab this week

All grades except Homework Five and Lab Twelve should be up by then (May 1-2).

Final Exam is on May 6 5-7pm in Rawles 100.

All grades including Homework Five and Lab Twelve should be up by May 5, 11:59pm.

Mon Apr 28
Homework Five can be submitted in QuizSite at the latest Wednesday night.

Quizzes Eight and Nine have been posted. Lab Twelve (Quizzes 1-10) is due May 4.

Sat-Sun Apr 26-27
Grades updated. Please check and report missing grades.

A bigger update is under way, but please check already.

Hope your weekend will be a good one!

Fri Apr 25
Key of Midterm Two Makeup posted. Grades will be up soon.

Thu Apr 24
Text of Midterm Two Makeup Exam (administered today in class) has been posted (MTM).

Wed Apr 23
Please remember to register (dgerman-Q201) for the makeup in QuizSite.

Mon-Tue Apr 21-22
Here's the code developed in class on Tuesday:
import java.applet.*; 
import java.awt.*;
import java.awt.event.*;

/*  
  <applet code=One.class width=300 height=300></applet>
*/ 

public class One extends Applet implements MouseListener, 
                                           MouseMotionListener {
  public void init() { 
    e1 = new Eye();
    e2 = new Eye(); 
    n = new Nose(); 
    m = new Mouth();  
    this.addMouseListener(this); 
    this.addMouseMotionListener(this); 
  }
  public void paint(Graphics g) {
    e1.draw(g); 
    e2.draw(g); 
    n.draw(g); 
    m.draw(g, out); 
    System.out.println("paint has finished...");
  } 
  public void mouseDragged(MouseEvent e) { }
  public void mouseMoved(MouseEvent e) { 
    out = false;     
                
  }

  boolean out = true; 

  Eye e1, e2; 
  Nose n; 
  Mouth m;
  public void mousePressed(MouseEvent e) { }
  public void mouseReleased(MouseEvent e) { }
  public void mouseClicked(MouseEvent e) { }
  public void mouseExited(MouseEvent e) { 
    out = true;
    System.out.println("Out...");  
    repaint();
  }
  public void mouseEntered(MouseEvent e) { 
    out = false; 
    System.out.println("Back in!");  
    repaint(); 
  }

}

class Eye { 
  public void draw(Graphics g) { } 
}
class Nose { 
  public void draw(Graphics g) { } 
} 
class Mouth { 
  int x, y, width = 300, height = 150, start = 190, stop = 160; 
  public void draw(Graphics g, boolean out) { 
    if (out/* == true*/) {
      System.out.println("Broad smile."); 
      g.drawArc(x, y, width, height, start, stop);  
    } else { 
      System.out.println("Attentive smile..."); 
      g.drawArc(x, y, width, height, start + 40, stop - 2 * 40); 
    } 

  } 
}

Sat-Sun Apr 19-20
New quiz Quiz_Ten has been posted.

It's by far the most involved so it's better to post it first.

Two more are coming and that will be it (only ten in all).

Fri Apr 18
Evaluations will be kept open until May 15 but please submit them earlier.

Thu Apr 17
There's a Practical Exam Makeup tonight in lab.

You don't need to come to lab if you don't take the exam.

Everybody is more than welcome to the exam, of course.

Here's the code we developed in class today:

*
 <applet code="Six.class" width=600 height=600> </applet> 
 */

import java.awt.*;
import java.applet.*; 
import java.awt.event.*; 

public class Six extends Applet implements MouseMotionListener {

  Device[] d = new Device[8]; 

  // (100, 100, 60, 20, 100, 100); 

  public void init() { 
    this.addMouseMotionListener(this); 
    for (int i = 0; i < d.length; i++) {
      int xC = (int) (Math.random() * (2 * 180)) + (100 - 180); 
      int yC = (int) (Math.random() * (2 * 180)) + (100 - 180); 
      int R = (int) (Math.random() * (2 * 5)) + (60 - 5); 
      int r = (int) (Math.random() * (2 * 5)) + (20 - 5); 
      d[i] = new Device(xC,yC,R,r,xC,yC); 
    }
  }

  public void paint(Graphics g) {
    for (int i = 0; i < d.length; i++) d[i].draw(g);     
  }

  public void mouseMoved(MouseEvent e) { 
    for (int i = 0; i < d.length; i++) {
      d[i].xTarget = e.getX(); 
      d[i].yTarget = e.getY();
    } 
    repaint(); 
  } 

  public void mouseDragged(MouseEvent e) { } 

}

class Device {
  int xCenter, yCenter, Radius, radius, xTarget, yTarget; 
  Device(int xC, int yC, int R, int r, int xT, int yT) {
    xCenter = xC; yCenter = yC; 
    Radius = R; radius = r; 
    xTarget = xT; yTarget = yT; 

  }
  void draw(Graphics g) {
    g.drawOval(xCenter - Radius, yCenter - Radius, 2 * Radius, 2 * Radius); 

    int a, b; 

    // a = xCenter - radius; b = yCenter - radius; 

    double dist = Math.sqrt((xTarget - xCenter)*(xTarget - xCenter) 
                           +(yTarget - yCenter)*(yTarget - yCenter)); 

    if (dist < Radius - radius) { 
      a = xTarget - radius; b = yTarget - radius; 
    } else { 
      double t = (Radius - radius) / dist; 
      a = (int) (xCenter + t * (xTarget - xCenter)) - radius;     
      b = (int) (yCenter + t * (yTarget - yCenter)) - radius;     
    }

    g.fillOval(a, b, 2 * radius, 2 * radius); 

    g.drawLine(xCenter, yCenter, xTarget, yTarget); 
  }


}

Wed Apr 16
Evaluations should be ready to go (CSCI-A201-Instructor_Name).

More quizzes should be posted in QuizSite.

Solutions to practical makeup problems should be posted today.

Tue Apr 15
You have to do well on the final exam to feel good about it.

Here's the code we developed in class today:

import java.applet.*; 
import java.awt.*; 
import java.awt.event.*; 

/*
 <applet code="Two.class" width=300 height=300>

 </applet>
 */

public class Two extends Applet implements 
           MouseMotionListener, MouseListener {

  Eye a = new Eye(20, 20, 30, 30); 

  public void init() {
    this.addMouseMotionListener(this); 
    this.addMouseListener(this); 
  }

  public void paint(Graphics g) {
    a.draw(g); 
  }
  
  public void mouseDragged(MouseEvent e) { 
    // a.x = e.getX() - a.w / 2; 
    // a.y = e.getY() - a.h / 2; 
    a.w = e.getX() - a.x; 
    a.h = e.getY() - a.y; 
    repaint(); 
  }

  public void mouseMoved(MouseEvent e) { }

  public void mouseClicked(MouseEvent e) { }

  public void mousePressed(MouseEvent e) { 
    a.x = e.getX() - a.w / 2; 
    a.y = e.getY() - a.h / 2; 
    repaint(); 
  }

  public void mouseReleased(MouseEvent e) { }

  public void mouseEntered(MouseEvent e) { }

  public void mouseExited(MouseEvent e) { }

}

class Eye {
  int x, y, w, h; 
  Eye(int x, int y, int w, int h) {
    this.x = x; this.y = y; this.w = w; this.h = h; 
  }
  void draw(Graphics g) {
    g.drawOval(x, y, w, h); 
  } 
}

import java.applet.*; 
import java.awt.*; 
import java.awt.event.*; 

/*
 <applet code="One.class" width=300 height=300>

 </applet>
 */

public class One extends Applet implements 
           MouseMotionListener, MouseListener {

  public void init() {
    this.addMouseMotionListener(this); 
    this.addMouseListener(this); 
  }

  int x0 = 100, y0 = 10, x1 = 12, y1 = 120; 

  public void paint(Graphics g) {
    this.drawLine(x0, y0, x1, y1, g); 
  }
  
  void drawLine(int x0, int y0, 
                int x1, int y1, Graphics g) {
    for (double t = 0; t <= 1; t += 0.05) {
      int x = (int) (x0 + t * (x1 - x0)); 
      int y = (int) (y0 + t * (y1 - y0)); 
      // System.out.println(t); 
      g.setColor(Color.red); 
      g.fillOval(x, y, 6, 6); 
      g.setColor(Color.blue); 
      g.drawOval(x, y, 6, 6); 
    }
  }

public void mouseDragged(MouseEvent e) { 
  int x = e.getX(), y = e.getY(); 
  x1 = 300 - x; y1 = 300 - y; 
  this.repaint(); 
}

public void mouseMoved(MouseEvent e) { }

public void mouseClicked(MouseEvent e) { }

public void mousePressed(MouseEvent e) { 
  int x = e.getX(), y = e.getY(); 
  x0 = x; y0 = y; 
}

public void mouseReleased(MouseEvent e) { }

public void mouseEntered(MouseEvent e) { }

public void mouseExited(MouseEvent e) { }

}

Mon Apr 14
There are three help sessions this week, all in LH102:

Sat-Sun Apr 12-13
What's Due page has been updated through the end of the semester.

Review notes (27) for inheritance and abstract classes have been posted.

Homework Five has been posted. (Double buffering help is provided).

Thu-Fri Apr 10-11
Don't forget that Lab Ten is due in lab today.

Wed Apr 9
Here's the message sent to the list tonight.
Date: Wed, 9 Apr 2003 21:58:08 -0500 (EST)
From: Adrian German <dgerman@cs.indiana.edu>
To: A201 Spring 2003 Distr. List <dgerman@indiana.edu>
Subject: A201/A597/I210 Update

Dear A201/I210/A597 Friends,

I would like to remind everyone that the appointment script is located at

       http://burrowww.cs.indiana.edu:11400/cgi-bin/appts/schedule

I've had so far about 84 appointments in A201 and A348 (for a combined
enrollment of 260 students or so) so I estimate I will have about twice as
many in the upcoming 7 days (appointments end next Tuesday). Please take a
brief moment to schedule an appointment so we can talk about your performance
in the course.

Grades are mostly up to date. Homework Five is the last homework and I have
not posted a due date yet. The list of problems for the Practical Makeup is
going to be finalized tomorrow at 5pm. There will be two more lab assignments
after Lab Ten (Eleven and Twelve) and that will be it, as far as assignments
go for A201 this semester. As I mentioned in class on Tuesday we're entering
the last phase of the course, with a two-three week period of review in which
we will be using mostly the textbook (Big Java, chapters covered thus far).

There's a Practical Makeup next week. A Midterm Two Makeup the week after,
that will also serve as a Warmup for the final. The Final is on May 6 and you
will have an option to choose the format -- you will have to communicate it
to me (through QuizSite) the format you prefer: either a problem from the ones
that you are preparing for the Practical Makeup or a multiple-choice test with
questions from QuizSite. All remaining exams (the two makeups and the final)
will be closed-book, closed-notes, no resources other than your own knowledge.

Please let me know if you need any help and don't forget to make an
appointment on-line (at the URL indicated above) so we can meet and talk
about the course and you to be sure that everybody is approaching these last
few weeks of review and makeup opportunities in the best possible way.

... Adrian
Here's the code we developed in class yesterday:
/*

  <applet code="One.class" width=300 height=300>

  </applet>

 */ 

import java.applet.*; 
import java.awt.*; 
import java.awt.event.*; 

public class One extends Applet {

  public void init() {
    Umpire a = new Umpire(); 
    this.addMouseMotionListener(a); 
  }

  public void paint(Graphics g) {
    for (int i = 0; i < 100; i++) {
       int x = (int)(Math.random() * 250 + 25),
           y = (int)(Math.random() * 250 + 25),
           w = (int)(Math.random() * 50 + 50),
           h = (int)(Math.random() * 50 + 50);   

       Color c = new Color((int)(Math.random()*255),
                           (int)(Math.random()*255),
                           (int)(Math.random()*255)
                          );  
       g.setColor(c); 
       g.fillOval(x, y, w, h); 
       g.setColor(Color.black);
       g.drawOval(x, y, w, h); 
    }
  }  
}

class Umpire implements MouseMotionListener {
  public void mouseDragged(MouseEvent e) {
    
  }
  public void mouseMoved(MouseEvent e) {
    System.out.println("Mouse at: (" + e.getX() + ", " + e.getY() + ")"); 
  }
}

Tue Apr 8
Pool of Elligible Problems:
  1. (for the Practical Makeup)
  2. are being collected here.
Also see Apr 17-18 entry for a direct link.

Mon Apr 7
Over the next few days my office hours are as listed here.

Please come during these times to make sure I am here.

Sat-Sun Apr 5-6
Please schedule your individual appointment here.

The PRACTICAL MAKE-UP will be on Apr 17-18, in lab(s).

The MIDTERM TWO MAKE-UP will be on Apr 24, in class (RH 100).

Details to follow.

Fri Apr 4
Midterm Two scores posted.

The average was 69.77 and the standard deviation was 16 (both out of 100).

Here's the distribution of scores:

above 95:   6 ******
   90-95   13 *************
   85-90   17 *****************
   80-85   13 *************
   70-80   36 ************************************
   60-70   29 *****************************
   50-60   27 ***************************
below 50   20 ********************
The maximum score was 99 (55 questions at 1.8 points each).

Thu Apr 3
Please start scheduling individual appointments here.

Here's the midterm of yesterday.

If you look closely you will realize

The only thing that's different is the picture, basically...

Wed Apr 2
Midterm Two today:

  1. Morrison Hall 007
  2. tonight between 7-9pm
  3. 30-60 multiple choice exercises
  4. need a No. 2 pencil
  5. open book, open notes
  6. but individual work
  7. bring a picture ID with you

Morrison Hall 007
(7-9pm bring picture ID
bring No.2 pencil)

Tue Apr 1
Lecture Notes Twenty-One posted.

Today in class we will discuss QuizSite exercises for tomorrow's exam.

Mon Mar 31
Don't forget there's a Help Session tonight in Geology 126 at 7:15pm.

Sat-Sun Mar 29-30
I am going to post a reading assignment for the next week's exam here.

Please take the time to check the QuizSite exercises available.

Here's some help with eliminating the leading zero(e)s:

class Example {
  public static void main(String[] args) {
    String[] numbers = args; // = { "0000070001",  "0000000000",  "9000000000" }; 
    for (int i = 0; i < numbers.length; i++) {  
      System.out.println(Example.transform(numbers[i])); 
    }
  }
  public static String transform(String number) { // our focus, actually...
    String result = "";
    boolean done = false; 
    for (int i = 0; i < number.length(); i++) { 
      if ((!done) && (number.charAt(i) == '0') && (i != number.length() - 1) ) 
        result += "_"; 
      else { 
        result += number.charAt(i); 
        done = true; 
      }
    }
    return result;     
  }
}
Notice that this is written in the style required for Lab Eight.

Here's how it runs:

drJava> java Example 00000001 90000000 90010000 00010001 00000000
_______1
90000000
90010000
___10001
_______0
We're using the command line arguments so we don't compile every time.

Thu-Fri Mar 27-28
Homework and Exam(s) Help Session

  1. in Geology Building room 126
  2. this coming Monday (March 31)
  3. between 7:15-9:15pm.

Midterm Two Exam is next Wednesday, Morrison 007 (7-9pm).

Midterm Two is multiple-choice, open book, study quizzes in QuizSite.

Lab Eight is now due on-line (in QuizSite, like Lab Seven) on Wed, Apr 2.

Wed Mar 26
Please use this method to read input from the user with DrJava:
import javax.swing.JOptionPane;

class One {
    public static void main(String[] args) {
	String in1, in2;
	int n1, n2; 
	in1 = JOptionPane.showInputDialog("Please enter the first number"); 
	n1 = Integer.parseInt(in1); 
	in2 = JOptionPane.showInputDialog("Please enter the second number"); 
	n2 = Integer.parseInt(in2); 
	System.out.println("max(" + n1 + ", " + n2 + ") = " + 
			   (n1 + n2 + Math.abs(n1 - n2)) / 2); 
    }
}
If this doesn't seem to work only use DrJava to compile.

The Second Midterm will be (on April 2) a multiple-choice, open-book exam.

The Make-up Practical Exam will be graded by the AIs.

Tue Mar 25
The make-up practical will be a closed-book exam, to be administered after April 15 (or so).

It will ask you to develop a program, e.g. one of the following:

  1. Report
  2. Line
  3. Clock
  4. Paper
  5. Tigger
  6. Oracle
  7. Elevator
  8. Hanoi
  9. Fraction

... and many more (say, up to about 50 programs).

So by the end of this week (Mar 28) I will post here a complete list of problems.

The problems on the list will be posted with a solution.

For the make-up practical you need to

  1. study the problems,
  2. understand the solutions, and
  3. be ready to solve any one (but only one) of them, during the exam.

During the make-up practical proctors may take and answer simple API questions.

The problem you will get on the make-up practical will be:

And the exam is closed-book

Mon Mar 24
Here's one student candid comment during the Practical Exam:

"I have been trying to get the parseInt to work all night.

This program should read all the numbers

... and then see if they can divide by two if they do then they get the paranthesis."

This is a very important comment.

Here's the Bracketizer as a number Historian:

import java.util.*; 

class Bracketizer {

    int[] memory;
    int available; 

    Bracketizer(int size) { 
	this.memory = new int[size]; 
    }

    void record(int n) {
	this.memory[available] = n; 
	this.available += 1; 
    }

    void report() {
	for (int i = 0; i < this.available; i++) 
	    if (this.memory[i] % 2 == 0) 
		System.out.print("(" + this.memory[i] + ") "); 
	    else System.out.print("[" + this.memory[i] + "] "); 
	System.out.println(); 	
    }

    public static void main(String[] args) {
	ConsoleReader c = new ConsoleReader(System.in); 
	String line; 
	System.out.println("Welcome to the [B][r](a)[c][k](e)[t](i)[z](e)[r]"); 
	System.out.print("enter> "); 
	line = c.readLine(); 
	while (! line.equals("done")) {
	    StringTokenizer stapler = new StringTokenizer(line); 
	    Bracketizer stanley = new Bracketizer(stapler.countTokens()); 
	    while (stapler.hasMoreTokens())
		stanley.record(Integer.parseInt(stapler.nextToken())); 
	    stanley.report(); 
	    System.out.print("enter> ");
	    line = c.readLine(); 
	}
    }

}
Here's how it runs:
frilled.cs.indiana.edu%javac *.java
frilled.cs.indiana.edu%java Bracketizer
Welcome to the [B][r](a)[c][k](e)[t](i)[z](e)[r]
enter> 1 2 3 4 5
[1] (2) [3] (4) [5] 
enter> 

enter> -1 -2 -3 0 0 0 1 100 200 101 201
[-1] (-2) [-3] (0) (0) (0) [1] (100) (200) [101] [201] 
enter> done
frilled.cs.indiana.edu%
Note that:
  1. to print arrays we need to
  2. print their elements one by one.

Sun Mar 23
Date: Fri, 14 Mar 2003 12:22:41 -0500 (EST)
From: Adrian German <dgerman@cs.indiana.edu>
To: A201/A597/I210 Spring 2003 Distr. List <dgerman@indiana.edu>
Cc: Adrian German 
Subject: A201 Spring Break Update


Dear A201/A597/I210 friends,

I am writing mostly to wish you a good break, and to let you know that
after the break (and before the second midterm exam scheduled on the 2nd
of April) I plan to set up individual appointments with each one of you,
to discuss your performance in the course thus far, in the first midterm,
the make-up (if any,) and the practical. Since we come back on March 22,
that means we have about 10 days between when school starts and when we
need to take the second midterm exam, and in those 10 days I want to talk
to each one of you. Since I co-teach 2 lab sections I'll probably focus on
those of you that I haven't worked with directly, thus far, mostly, since
I would be talking with the rest in the lab. E-mail appointments will be
acceptable also, under certain circumstances, to be detailed later. So
when we come back from the break I will have details on how we arrange
these individual appointments, to make sure we all finish this semester
in triumph (or as close to that as we could possibly get).

Have a great break and we'll be seeing you (literally) when you come back.

... Adrian

P.S. We're still updating the grades. Grades will be updated throughout
the day today and tomorrow, before we close the gradebook for the break.

Mon-Sat Mar 17-22
Happy Spring Break!

Sun Mar 16
After the break we'll switch to using Dr. Java in labs.

If you want to install it on your computers you should download the latest (current) stable release. DrJava is a lightweight development environment for writing Java programs. It is designed primarily for students, providing an intuitive interface and the ability to interactively evaluate Java code. It also includes powerful features for more advanced users. DrJava is available for free under an open source license (GPL), and it is under active development by the JavaPLT group at Rice University.

Sat Mar 15
A better version of the Historian code:

import java.util.*; 

class Historian {
    int max = 0; 
    int min = 0; 
    int sum = 0; 
    int num = 0;

    void record(int a) {
	this.sum += a; 	
	if (this.num == 0) {
	    this.min = a;
	    this.max = a;
	}
	if (this.min > a) this.min = a; // a bit redun- 
	if (this.max < a) this.max = a; // dant sometimes 
	this.num += 1; // order of updates is important!
    }

    void report() {
	if (this.num == 0) {
	    System.out.println("Nothing to report on..."); 
	} else {
	    System.out.println
		(
		 "  I've looked at " + this.num + " number(s) thus far.\n" +
		 "  The largest I've seen was " + this.max + 
		 "\n  The smallest was " + this.min + 
		 "\n  The average of the numbers is " + 
		 this.sum / (double) this.num
		 ); 
	}

    }

    // testing... 

    public static void main(String[] args) {
	ConsoleReader c = new ConsoleReader(System.in); 
	String line; 
	System.out.println("Welcome to the Historian!"); 
	System.out.print("enter> "); 
	line = c.readLine(); 
	while (! line.equals("done")) {
	    StringTokenizer stapler = new StringTokenizer(line); 
	    Historian herodotus = new Historian(); 
	    while (stapler.hasMoreTokens()) {
		herodotus.record(
				 Integer.parseInt(
						  stapler.nextToken())); 
	    }
	    herodotus.report(); 
	    System.out.print("enter> ");
	    line = c.readLine(); 
	}
    }

}
Note we're getting closer to arrays, but we're not there yet.

Notice also that every Historian works with a stapler.

Here's a session with this program:

frilled.cs.indiana.edu%java Historian
Welcome to the Historian!
enter> 1 2 3
  I've looked at 3 number(s) thus far.
  The largest I've seen was 3
  The smallest was 1
  The average of the numbers is 2.0
enter> -1 -3 4 2 5 0 -1 
  I've looked at 7 number(s) thus far.
  The largest I've seen was 5
  The smallest was -3
  The average of the numbers is 0.8571428571428571
enter> 
Nothing to report on...
enter> 0
  I've looked at 1 number(s) thus far.
  The largest I've seen was 0
  The smallest was 0
  The average of the numbers is 0.0
enter> done
frilled.cs.indiana.edu%
The empty line problem is solved with a count of numbers seen thus far.

This solution was suggested in about 8 minute papers on Tuesday.

Fri Mar 14
Some of the code from Tuesday:
class Historian {
  int gTF = 0; // greatestThusFar
  boolean start = false; 
  void feed(int a) { 
    if (start) { 
      if (a > this.gTF) { 
        this.gTF = a; 
        // start = true; 
      } 
    } else {
      this.gTF = a; 
      start = true;
    }
  }
  void report() {
    if (start) {
      System.out.println("Max: " + this.gTF); 
    } else {
      System.out.println("We haven't started yet."); 
    }
  }
  public static void main(String[] args) {
    Historian a = new Historian();
    a.report(); 
    for (int i = 0; i < 6; i++) {
      int n = (int)(Math.random() * 100); 
      System.out.print("Chosen: " + n + " "); a.report(); 
      a.feed(n); 
    }
    a.report(); 
  }
}

Thu Mar 13
Homework Four is a watershed for us and this semester.

  1. If you know these things, Homework Four is EASY.

  2. If it doesn't seem easy to you, you need to KNOW (and work out) these problems.

Thus Homework Four it's either EASY or NECESSARY!

Wed Mar 12
Please pay special attention to Homework Four.

Nothing is due in labs this week.

So we will use the lab(s) as follows this week:

Especially the last point will be fundamental.

Tue Mar 11
Lecture and lab notes for the week after the break posted as well.

Please note the due dates of Homework Four and labs Eight and Nine.

The Second Midterm Exam is on April 2, 2003.

Sun-Mon Mar 9-10
Lecture and lab notes for the upcoming week posted, along with Homework Four.

Sat Mar 8
With this exam we are bouncing into Graceland.

This exam is a learning experience:

  1. enjoy it,
  2. learn from it,
  3. don't give up on it.

Try to

  1. learn from your problem and
  2. solve it before next lab (next week).
.
... like a window in your heart

Thu-Fri Mar 6-7
Practical Exam in labs today and tomorrow.

Please remember to be there on time.

Wed Mar 5
QuizSite is now ready for Homework Three and Lab Seven.

Tue Mar 4
Lecture notes for this week have been posted.

Here's the minute paper for today.

Consider the following program with a few lines missing:

class One {
  public static void main(String[] args) {
      int x = 3, y = 5;
      System.out.println("x = " + x + ", y = " + y); 

      // ... code erased here 
     
      System.out.println("x = " + x + ", y = " + y); 
  }
}
When you run this program (with the missing code in) one obtains:
frilled.cs.indiana.edu%java One
x = 3, y = 5
x = 5, y = 3
frilled.cs.indiana.edu%
Write the missing code without using anything else but x and y.

You can't use any other variable(s).

If you could, though, how would you do it?

Mon Mar 3
Please make sure you understand what your Homework Three really is.

You are to write the RootApproximator program to solve P6.12 on page 278 of Big Java.

Sat-Sun Mar 1-2
I am in Chicago over the weekend returning Monday for office hours.

Practical exam next week is

Web notes are fine but no e-mail, no chat, no file sharing is allowed.

Fri Feb 28
Here's the Midterm Makeup of Wednesday.

Thu Feb 27
Thanks to Pat Boesen for the following example:

class StrawDispenser {

  final static CAPACITY = 100; 

  int balance = StrawDispenser.CAPACITY; 

  Straw dispense() { 
    this.balance -= 1; 
    return new Straw(); 
  } 

  int getBalance() {
    return this.balance; 
  }

  void refill() {
    this.balance = StrawDispenser.CAPACITY; 
  }
}

A similar (perhaps even better) example would be this:

This is a bubble machine, in case you're wondering.

Wed Feb 26
Midterm One Makeup today:

  1. Morrison Hall 007
  2. tonight between 7-9pm
  3. 4-5 (perhaps 10) short questions
  4. short answers expected
  5. open book, open notes
  6. but individual work

Morrison Hall
(not Rawles).

Three more quizzes uploaded in QuizSite (dgerman-Q201)

Tue Feb 25
In lecture today we will review these problems.

Mon Feb 24
Lecture and lab notes for this week posted.

Two new quizzes posted in QuizSite so you can practice with loops.

Homework Three, posted, is due before the Practical Exam.

List of problems to be worked out before the Midterm Makeup updated.

Sat-Sun Feb 22-23
Exam next week is Wednesday February 26 7-9pm in Morrison Hall 007.

Here's a local copy of the same picture.

More details about the exam to be posted here soon.

Fri Feb 21
Midterm One Makeup is next week on Wednesday.

Details to follow. Tuesday lecture is a (New) Review.

Thu Feb 20
Here are the examples worked out on Tuesday in class:
class NumberTwo {
  Sandwich a; 
  Fries f; 
  Drink d; 
  NumberTwo(int size, String drink) {
    a = new Sandwich("cheeseburger"); 
    f = new Fries(size); 
    d = new Drink(drink, size); 
  } 
} 
And the Triangle exercise:
class Point {
  double x;
  double y;
  Point(double a, double b) {
    this.x = a;
    this.y = b;
  }
  double dist(Point other) {
    double dX = this.x - other.x,
           dY = this.y - other.y;
    return Math.sqrt( dX * dX + dY * dY);
  }
}

class Triangle {
  Point a, b, c;
  Triangle (double x1, double y1,
            double x2, double y2,
            double x3, double y3) {
    this.a = new Point(x1, y1);
    this.b = new Point(x2, y2);
    this.c = new Point(x3, y3);
  }
  double area() {
    double m = a.dist(b), n = b.dist(c), q = a.dist(c),
           s = (m + n + q) / 2;
    return Math.sqrt(s * (s - m) * (s - n) * (s - q));
  }
}

class Experiment {
  public static void main(String[] args) {
    Triangle a = new Triangle(0, 0, 0, 3, 4, 0);
    System.out.println(a.area());  // prints 3 * 4 / 2 (that is: 6 (six))
    System.out.println((new Point(0, 3)).dist(new Point(4, 0))); // (5.0)
  }
}

Wed Feb 19
There's a new Homework due next week, and a make-up Exam too.

Here's what you can practice with:

  1. Think about R1.1-R1.14 (pp. 30-31, Big Java)
  2. Think about P1.2, P1.5, and P1.6 (pp. 31-32, Big Java)
  3. Answer questions R2.1-R2.18 (pp. 72-74, Big Java)
  4. Solve problems P2.1-P2.17 (pp. 74-76, Big Java)
  5. Review questions R3.1-R3.19 (pp. 123-125, Big Java)
  6. Solve problems P3.1-P3.17 (pp. 125-131, Big Java)
  7. Answer questions R5.1-R5.20 (pp. 219-222, Big Java)
  8. Solve exercises P5.1-P5.18 (pp. 222-226, Big Java)

Solutions to most of these questions and problems can be found

Tue Feb 18
Here's the problem discussed in lab last week and its solution:

class Athlete { 

  String name;
  double weight;

  Athlete(String givenName, double givenWeight) {
    name = givenName; 
    weight = givenWeight;
  }

  void report() {
    System.out.println(name + ": " + weight);
  }

  void eat(int bagels) {
    this.report();
    System.out.println(            "My name is " + 
                                            name +
                  " and I am just about to eat " + 
                                          bagels + 
                                        " bagels."
                      );

    weight += bagels * 0.25;

    System.out.println(            "My name is " + 
                                            name +
                       " and I have just eaten " + 
                                          bagels + 
                                        " bagels."
                      );
    this.report();
  }

  void workOut(int minutes) {
    this.report();
    System.out.println(            "My name is " + 
                                            name +
         " and I am just about to work out for " + 
                                         minutes + 
                                       " minutes."
                      );

    double lostWeight = minutes / 20.0 * 0.75;

    weight -= lostWeight;

    System.out.println(            "My name is " + 
                                            name +
                    " and I am just finished a " + 
                                         minutes + 
                              " minutes work-out."
                      );
    this.report();
  }
}

class Story {
  public static void main(String[] args) {

    Athlete a = new Athlete("George Foreman", 300);
    a.report();

    Athlete b = new Athlete("Riddick Bowe"  , 250);
    b.report();

    a.eat(1000);

    b.eat(15);

    b.workOut(12000);

    b.eat(20000);

    // and so on 

  }
}
The problem, of course, read like this:

Implement a class Athlete. Our Athletes can do two things: eat(...) and workOut(...). When they eat() their weight goes up. When they workOut() their weight goes down. They eat (a number of ) bagels, they work out a number of hours. Every bagel that they eat raises the weight by 0.25 pounds. Every 20 minutes of work-out will lower their weight by 0.75 pounds. Athletes can report() their weight if they're asked to, and come into existence with a specific weight. (Later we also indicate that Athletes should also be able to report their name along with their weight.) Now write the story below:

Once upon a time there were two Athletes: one of them was called "George Foreman" and was created with a weight of 300 pounds, and another one was named "Riddick Bowe", created at about 250 pounds. They both reported their weights, then ate bagels. George ate 1,000 bagels, reported his new weight, then worked out for 1,200 minutes, and reported his weight again. He was able to report his name along with his weight, as Athletes always are. He then retired. Riddick's career was a bit different. He first ate about 15 bagels and then he started working-out. He worked out about 12,000 minutes non-stop, and when he finished he felt very hungry. So he ate about 20,000 bagels and then reported his name and weight. Then he also retired. That was the end of his career, and this is the end of our story.

Also, please don't forget to check the Jace problem below.

Mon Feb 17
Jace (Min-Hsiang Lee) has come up with a nice program that converts between base 2 (two) and base 10 (ten). His program assumes that numbers are below 256, positive and integers. But the rest is fairly nice. Below is the part that converts from base 10 (ten) to base 2 (two). Well-done, Jace! Way to go.

class Jace {
    public static void main(String[] args) {

	int number = 131;

	Wizard someone = new Wizard();

	int result = someone.convert(number);

	System.out.println(result);
	
	System.out.println(someone.convert(1));
	System.out.println(someone.convert(2));
	System.out.println(someone.convert(3));
	System.out.println(someone.convert(4));
	System.out.println(someone.convert(5));
	System.out.println(someone.convert(6));
	System.out.println(someone.convert(7));
	System.out.println(someone.convert(8));
	System.out.println(someone.convert(9));
	System.out.println(someone.convert(10));
	System.out.println(someone.convert(11));
	System.out.println(someone.convert(12));
	System.out.println(someone.convert(13));
	System.out.println(someone.convert(14));
	System.out.println(someone.convert(15));
	System.out.println(someone.convert(16));
	System.out.println(someone.convert(17));
	System.out.println(someone.convert(18));
	System.out.println(someone.convert(19));
	
    }
}

class Wizard {
    int convert(int x) {
	
	int y = 00000000;
	
	if ( x >= 128 ) { x = x - 128; y =     10000000; }
	if ( x >=  64 ) { x = x -  64; y = y +  1000000; }
	if ( x >=  32 ) { x = x -  32; y = y +   100000; }
	if ( x >=  16 ) { x = x -  16; y = y +    10000; }
	if ( x >=   8 ) { x = x -   8; y = y +     1000; }
	if ( x >=   4 ) { x = x -   4; y = y +      100; }
	if ( x >=   2 ) { x = x -   2; y = y +       10; }
	if ( x >=   1 ) { x = x -   1; y = y +        1; }
	
	return y;
	
    }
}
This is a good example of how delegating responsibilities simplifies the main program.

Sat-Sun Feb 15-16
Here's a pointer to Heron's formula.

Fri Feb 14

Happy Valentine's Day!

  1. Lab and lecture notes for the upcoming weeks
  2. (including Homework Assignment Two)
have been posted (with due dates where appropriate).

Thu Feb 13
I'll post the key to the Midterm Exam (and try to have it graded) today.

Wed Feb 12
Subject: Midterm One

Dear A201/A597/I210 Friends,

Midterm Exam is today Wed 2/12 7-9pm in Jordan Hall 124.

Bring a No. 2 pencil and a picture ID with you.

(Your picture ID).

Exam is open book and open notes.

You can rely on

  • anything you bring with you
  • (except another person or a computer).

Exam is individual work.

Good luck and see you tonight.

... Adrian

Jordan Hall
(not Rawles).

Tue Feb 11
Tutor list updated:
1. Scott McCarthy (slmccart@cs.indiana.edu)
2. Anastasiya Chagrova (achagrov@cs.indiana.edu)
3. Reuben Wilson (reujwils@cs.indiana.edu)
4. Steven Bogaerts (sbogaert@cs.indiana.edu)
5. Andrew Strain (ajstrain@cs.indiana.edu)

Mon Feb 10
Lecture on Tuesday will discuss all quiz items in QuizSite.

Sat-Sun Feb 8-9
Date: Sat, 8 Feb 2003 17:49:33 -0500 (EST)
From: Adrian German <dgerman@cs.indiana.edu>
To: A201 Spring 2003 Distr. List 
Subject: A201 Distribution List


Dear A201/A597/I210 Friends,

I have finally created a distribution list and I am using it now to
send a first message. I plan to use this list perhaps once a week to
keep you informed of things that you might otherwise miss if posted
on the web only.

Please don't forget the four quizzes in QuizSite. Use your notes and
the book and all the knowledge you have to solve all exercises. The
exam on Wednesday will be composed of questions very much like the
ones in the quizzes. Essentially identical in _structure_. The exam
is open book, Wed Feb 12, 7-9pm in Jordan 124, bring a No. 2 pencil
since the exam is (as expected, and as announced) multiple choice.

Please write to me if you need help with the quizzes. Identify the
problem by quiz and number and I will try to get back to you with a
quick answer. On Monday I will try to collect a list of "difficult"
questions from you (perhaps through QuizSite or by e-mail) so we can
review especially those in class on Tuesday.

Hope your weekend is coming along fine.

If you need help please let me know.

... Adrian

P.S. If you receive this message in error or if you don't want or
don't need to be on this list please let me know and I will remove
your username from the list. Thanks and all the best.

Fri Feb 7
Homework One due date extended 2 days.

The assignment is now due tonight, Friday, in QuizSite (dgerman-Q201).

QuizSite and Postem rosters updated throughout.

Please check and report any errors and/or omissions.

Thu Feb 6
The Midterm Exam will consist of items similar to those in the QuizSite exercises.

Here they are for your review as part of the course packet: One Two Three Four.

Take them to learn (by experimentation and discovery), and not to test yourselves.

After you're done with them also study (to learn through it) this older test.

(It is the first midterm exam from Spring 2002 as administered then).

Wed Feb 5
Lab Notes Four have been posted.

The first Midterm Exam is next week in Jordan Hall Room 124 (7-9pm).

It's an open-book, multiple choice exam.

Check the

  1. reading assignment (What's Due? for Tue Feb 4)
  2. and practice quizzes in QuizSite to get ready for the exam next week.

Especially the quizzes are important.

Tue Feb 5
Reading assignment for
  1. this week and
  2. the upcoming exam (Midterm One, a week from tomorrow)
has been detailed on the What's Due page under today's date.

Mon Feb  3
Three more practice quizzes posted in QuizSite.

The first midterm exam (next week) will be multiple choice.

Sun Feb  2
Just a reminder that the course packet(s) are available on-line:

  1. There's a link under the schedule of Class Notes,
  2. and here's a direct link too.

There's a set of lecture notes, and another one of lab notes and exercises.

Sat Feb  1
QuizSite updated to allow submission of Homework One.

Reading assignments for next week will focus on:

  1. Chapter 3 (new assignment)
  2. Chapters 1, and 2 (complete overview)
  3. Also review the part covered from Chapter 5.

A more detailed (page by page) reading assignment will be posted on

What's Due? (with icon)

Thu-Fri Jan 30-31
Lecture notes for next week have been posted.

Wed Jan 29
Postem (A201-1216) has been updated as well (on Wednesday).

The style guide.

Tue Jan 28
QuizSite has been initialized (please use section dgerman-Q201).

Mon Jan 27
Tutor list updated:
1. Anastasiya Chagrova (achagrov@cs.indiana.edu)
2. Reuben Wilson (reujwils@cs.indiana.edu)
3. Steven Bogaerts (sbogaert@cs.indiana.edu)
4. Andrew Strain (ajstrain@cs.indiana.edu)

Sat-Sun Jan 25-26
Lecture and lab notes for this week have been posted.

We're now starting to write real programs (that solve actual problems)!

Fri Jan 24
QuizSite will be set up during the weekend.

Thu Jan 23
Lab Notes Two bring up the following (not to be overlooked):

  1. Warmup Exercises (with Solutions)
  2. Practice Problems (with Solutions)
  3. Your Lab Assignment Two

Also, Homework Assignment One has been posted.

(It's very similar to Lab Assignment Two).

Wed Jan 22
I have a list of tutors I need to post. Here's a start:

1. Reuben Wilson (reujwils)
2. Steven Bogaerts (sbogaert)
3. Andrew Strain (ajstrain)
These are good people. Contact and make arrangements directly with them.

Tue Jan 21
The other way of compiling and running Java is using Dr. Java.

Alternatively, you can download Emacs. (Here's a reference card for Emacs, to help you use it more effectively). Remember that no editor (or any Java IDE for that matter) is Java. What we mean by Java is essentially encapsulated in two programs: javac and java. The rest is ancillary material related to development. But Emacs is the superior editor!

(Emacs installation is a bit old, I will try to update it soon).

Sun-Mon Jan 19-20
Monday (Jan 20, 2003) I am available if you need me.

Fri-Sat Jan 17-18
A web-based bulletin board has been set up for this class. Please use it to post questions and read answers to frequently asked questions. Keep in mind that you can always also contact us individually by e-mail. Don't be afraid to post, and remember: if at first you don't succeed, try posting something that is politically incorrect. It will go through.

Wed-Thu Jan 15-16
I have received a few questions on installing Java.

Here are the most relevant steps (all of them):

  1. You need to start here first.
  2. Clicking on Microsft Windows takes you here.
  3. The Checklist is the fundamental item on that page.
  4. It describes where to download from and what

    Windows (all languages, including English) SDK (not JRE)

  5. So click in the second line, second column in the table in this page.

  6. Then you need to read the installation instructions, carefully.
  7. The most important things in those involves updating the PATH variable.
  8. Then you can go to the tutorial page again and check that all's working well.

Alternatives to be described later are Dr. Java and Emacs.

Please contact me (dgerman@indiana.edu) if you need more info.

Tue Jan 14
First lecture in RH (Rawles Hall) 100 at 4pm today.

Mon Jan 13
Spring Semester 2003 starts.


Updated by Adrian German for A201/A597 and I210