CSC 216 F09/JavaBall

From Expertiza_Wiki
Revision as of 19:32, 17 November 2009 by Dschung2 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

JavaBall

The problem

In this activity, we want to teach students the topic on exceptions so that they can utilize this important concept into their programs.

Participants and props

The whole class will participate in this activity. The class will be divided into teams. Number of teams depends on how large the class is. For this write-up, assume there are 50 students in the class, so there are 5 teams of 10 students. The instructor needs to prepare a ball, preferably a ball smaller than a basketball that can fit into a trashcan and that can also bounce. A trashcan or a basket is also required. Tape is required to designate lines onto the floor that will represent a point system.

Setup

The instructor must set up a point system for this activity. The trashcan/basket should be placed in the front of the classroom, and starting from about 7 feet away, place lines of tape onto the floor with the number of points written on the tape. The intervals should be about 1-1.5 ft apart. The first line can be 1 pt, and second line can be 2 pts, etc. The instructor may decide how many lines he wants, 3 lines are preferred.

There is one "ultimate shot" area, which could be looked as a "full-court shot". The instructor can decide where this area will be, preferably across the other side of the room. Since this is the toughest shot in the game, many points are awarded if someone makes this shot. For this write-up, we will assume this shot will be worth 10 points.

Rules

1. The instructor will give a question, and each team has about 1-2 minutes to answer the question.

2. Each team should whisper so that they don't give away the answer to other groups.

3. The answer should be written on a piece of paper, or can be submitted via google doc, if the instructor has prepared a spreadsheet.

4. After time is up, the instructor will check the answers (if the team has answered the question correctly, they are given 1 point; if the team has answered incorrectly, no points are allotted).

5. When a team has answered a question correctly, they are given the opportunity to score more points by shooting a basket in front of the class.

6. The shooter can decide which line they want to shoot from.

7. If the shooter makes the shot, he/she is allotted that number of points written on the piece of tape.

  • BONUS POINT: If shooter can bounce the ball on the floor and make the basket, an extra point will be given.

8. No student can shoot again until all members of the team have shot at least once.

9. The team with the most accumulated points at the end wins.

Questions

Questions regarding exceptions can vary. The questions we came up with are of several types:

1. Code is provided, students decide which exception will be thrown.

  private int r = 7;
  private int zero = 0;
  private int newNumber;
  public static void main(String args[]){
       newNumber = r/zero;
       System.out.println(newNumber);
  }

Which exception would be thrown in this code? Answer: ArithmeticException

2. Exception will be provided, students determine what the exception does exactly and when its thrown.

ClassCast Exception -Definition: Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance.

3. A description of an exception is provided, students determine the exception.

What Runtime Exception is thrown when an application attempts to use null in a case where an object is required? --NullPointer Exception

Acknowledgments

This activity was created by David Chung and Manpreet Singh.