Computer Science 252
Problem Solving with Java
Spring 2015, The College of Saint Rose
Lecture 21: Arrays
Date: Tuesday, April 7, 2015
Agenda
- Announcements
- Exam 3 in one week
- same ground rules as Exam 1 - closed book, closed
notes, closed network, closed neighbors, but relevant
portions of the reference card will be provided
- topic focus is on those since the first exam, but of
course the material is cumulative by nature: active objects,
Java interfaces, Java Swing GUI, Recursion, ArrayLists.
Note that our new topic of arrays is not covered.
- optional review session Monday 4/13, 8:30 PM, Albertus 205
- practice exam questions out
- Lab 9: Final Project design phase is
underway, designs will be accepted without penalty through April
16, but you are encouraged to do them sooner
- Lab 10: ArrayList Practice due Friday
- In-class Exercise 21 - (15 lecture assignment
points) due before the end of class.
We will work together to develop a Java application that includes a
few methods that use ArrayLists. Methods will include
- the one we
saw previously to find the sum of an ArrayList of Integer
- one that takes a second int parameter in addition to the
ArrayList and returns another ArrayList of Boolean
where each entry indicates whether the corresponding entry in the
original ArrayList is evenly divisible by the given int
- one that returns whether the input ArrayList has any zero
values.
Please submit only the file
ArrayListPractice.java in
Submission Box
under "InClass21" before you leave class.
- Introduction to arrays
- Time to work on labs and lecture assignment
Lecture 21 Assignment
Due at the start of class, Thursday, April 9.
Please submit answers to these questions
in Submission
Box under "LA21" or in hard copy by the
start of our next class. We will discuss these questions at the
start of class, so no late submissions are accepted. Please be sure
that your name is clearly indicated in all submissions.
There are a lot of questions here, but none are especially long. Just
take your best shot and don't spend a ton of time agonizing over any
of them.
- 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)
- Write a method that takes an array of double values as its
parameter and returns the sum of all elements in the array. (4 points)
- BDM Exercise 14.2.1, p. 358. (5 points)
- BDM Exercise 14.3.1, p. 363. (2 points)
- BDM Exercise 14.3.3, p. 364. (3 points)
- BDM Exercise 14.5.2, p. 373. (6 points)
Terminology
Examples