Computer Science 252
Problem Solving with Java

Spring 2016, The College of Saint Rose

Lecture 21: Arrays
Date: Tuesday, April 12, 2016


Agenda

Lecture 21 Assignment

Due at the start of class, Thursday, April 14.

Please submit answers to these questions either as a hard copy (typeset or handwritten are OK) or by email to terescoj AT strose.edu by the start of class. Please use a clear subject line when submitting by email (e.g., CSC 252 Lecture 21 Assignment, Mary Smith). We will discuss these questions at the start of class, so no late submissions are accepted.

There are a lot of questions here, but most are not especially long. Only the last one will take you some time. Just take your best shot and don't spend a ton of time agonizing over any of them.

  1. Write a method that takes an ArrayList of FilledOval object references as its parameter and returns the count of how many of those FilledOvals are circles. (5 points)
  2. Write a method that takes an ArrayList of FilledOval object references as its parameter and returns an ArrayList of Boolean where each entry contains a value indicating whether the value at the corresponding index in the input ArrayList represents a circle. (5 points)

    For example, if the dimensions of the FilledOvals in the input are 54×12, 98 ×98, and 123 ×123, the returned ArrayList should contain three Boolean objects, the first of which encapsulates the value false, and the second and third encapsulate the value true.

  3. Write instance variable declarations that would declare and construct an array that would hold each of the following. (3 points)

    For example, if asked to construct an array that would store student identification numbers for a class of 100 students, an appropriate answer would be:

        private int[] idNums = new int[100];
    
    1. an array used to hold the populations of the 25 largest cities in New York state
    2. an array used to hold the titles of the chapters of the book Harry Potter and the Half Blood Prince (note: it has 30 chapters)
    3. an array used to hold 7 FilledRects that together form a picture of a picket fence

Terminology

Examples