Computer Science 15-111 (Sections A & B), Spring 2007

Class Notes:  29-Jan-2007

 

Logistics

  1. hw3 and hw2.ec due at 8pm tonight
  2. Quiz 2:  Wed, 31-Feb-2007 in class
  3. Poll:  quiz 2 review projected attendance
  4. Quiz 1 Retake:  Fri, 2-Feb-2007 in class
  5. JCreator and DrJava
  6. Reading:
    1. Mon:  Ch. 6.6 to 6.10  (and 6.0 - 6.5)
    2. Wed:  Ch  6.11 to 6.16
    3. Fri:     Ch 6.17 to 6.19

Topic Outline:

 

1.      On Style:  “Magic Numbers”

a.      A simple rule:  no literals in expressions besides -2, -1, 0, 1, 2.

b.      Bad:    drawCircle(pixels,250,50,50,…)

c.      Better: drawCircle(pixels,width-radius,radius,radius,..)

d.      Reads better, fewer bugs, more easily modified, etc, etc, etc…

2.      Enumeration Operations (Section 6.4)

a.      equals(), name(), ordinal(), values()

b.    FadeType type1, type2;
if (type1.equals(type2)) { … }  // not equals(type1,type2)

c.   for (FadeType fadeType : FadeType.values()) {
   System.out.printf("%d: %s\n”,fadeType.ordinal(),
                                fadeType.name());
}

Outputs:
   0: HORIZONTAL_FADE
   1: VERTICAL_FADE
   2: RADIAL_FADE

3.      Classes:  a 10-minute tour of Sections 6.6 to 6.10

a.      Create a new class (Counter)

b.      Adding instance variables (value)

c.      Adding instance methods (get(), click(), reset())

d.      Making instance variables private

e.      Counting instances

                                                   i.      Adding a constructor (and losing the default constructor!)

                                                 ii.      Adding a static (class) variable -- howMany

                                                iii.      Adding a static (class) method  -- howMany()

4.      Pixel image demo part 2:  Zooms and/or Thumbnails of jpegs!

5.      2d Arrays:  Either matrix operations or Gaussian Elimination (depending on time)