CSE142 Spring Quarter
University of Washington
Miniquiz #11B
Thursday, June 5, 2003 

  Closed book, closed notes, closed neighbor

  
. 5 pts. 2 for the header, the rest for the implementation.
Every year, a census of birds is taken on April 1.  Bird watchers in each district count how many birds they see of each species of interest.  The result are collected into a 2-D array, with one row for each district and one column for each bird species. Define a method which, given a species (an index number) and a 2-D array of data, returns how many different districts actually saw birds of that species.  Implement the method. 

These constants exist:

final static int NUMD = ... //number of districts

final static int NUMS = ...  //number of species

Otherwise, the method doesn't depend on any instance or class data. 


      public int countD(int[][] data, int sIndex) { //"public static" optional
                int count = 0;
                for (int d = 0; d < NUMD; d++) {
                        if (data[d][sIndex] > 0) {
                                count++;
                        }
                }
                return count;
        }

    
 
. 5 points (-1 for each missing or incorrect arrow)
Here's what you know about how a set of classes are related:

A is a subclass of C

B extends A

D is-a E

C is the base class of E

Draw a diagram to show how the classes are related.  Make one rectangle per class.  Draw an arrow from X to Y if X extends Y.

Should be 4 arrows: A to C, B to A, D to E, E to C.