Sections

Each week you will complete problem(s) to turn in at your section. These problems will earn you up to 2 out of your 3 section participation points for the week. The other point is awarded for being present in your section and participating in the discussion.

You will not be graded on whether you have a perfect solution, but on whether you have demonstrated effort. Therefore please show some work that demonstrates how you got the answer rather than just writing the answer by itself. We will be somewhat lenient about exactly how the work is shown.

Our intention is that these problems would take you up to 30 minutes each week. If you find yourself taking significantly more than this, you may stop your work and write that you worked for 30 minutes. If you have made significant progress, we will still give you credit for your work.

Section 8: Classes and objects (Thu Aug 9)

Exercises: Solve the following three (3) Self-Check problems on paper and bring your sheet of paper to your section on Thursday:

  1. Chapter 8, Self-Check #2: what is an object? (p548). Answer the question in your own words.

  2. Chapter 8, Self-Check #15: problems with constructor (p549). Write the two problems with the constructor shown, and then show a corrected version that does not contain these two problems.

  3. TimeSpan Object: A TimeSpan object stores a span of time in hours and minutes (for example, the time span between 8:00am and 10:30am is 2hours, 30 minutes). The description implies that a TimeSpan object stores hours and minutes. What would be an alternative way of storing the same information? Are there any reasons why one would be better than the other? What would happen if you wanted a method that added hours and minutes to the TimeSpan object? See pages 532-538 in the book for ideas.

Section 3: Parameters, graphics, returns (Thu 7/5)

Correction to problem 3 of section handout

Exercises: Solve the following three (2) problems on paper and bring your sheet of paper to your section on Thursday.

  1. Graphics Problem:
    Write the statements to reproduce this image: Red circle inside a black square
    The top left corner is at (0,0). The width and height of the square and circle are each 50 pixels. The square is black and the circle is red. Assume that you have access to a Graphics object named g.
  2. Returns: List two reasons why we use returns

Section 1: Printing, static methods, expressions (Thu 6/21)

Write a println statement that prints the following text:

"I like printing backslashes \\" -Nick
"You're weird" -Student
  

What is the value computed by the following expressions:
a) 1 + 2 * 4 + 3
b) 1 + 2.0 * 4 + 3
c) (1 + 2.0) * 4 + 3
d) "1" + 2.0 * 4 + 3
e) 1 + "2.0 * 4" + 3
f) 13 / 3
g) 13 % 3
Remember our precedence rules and left-to-right evaluation!