Computer Science 210

Data Structures

Fall 2016, Siena College

Agenda

- Announcements
- Looking for lots of examples of prerequisite Java constructs? Check out one of my old classes. (Definitely some overlap with the examples I went through earlier.)
- Lab 2: Lottery Simulator continues
- Lecture 03 assignment recap
- Classes
- Object-orientation

Due at the start of class, Monday, September 19.

Please submit answers to these questions by the start of class. zyBook activities should be done right in your zyBook, and all others should be submitted to Blackboard under "Lecture 05 Assignment" . We will discuss these questions at the start of class, so no late submissions can be accepted.

- Write a new mutator method for the
`Ratio`class in the Ratios example that takes an`int`parameter and multiplies the value of the ratio by that number. Recall that you can multiply the value of a ratio by a value by multiplying its numerator by that number. Do not worry about reducing to lowest terms or any other simplifications. (5 points) - Write a new mutator method for the
`Ratio`class in the Ratios example that takes a`Ratio`parameter and multiplies the value of this ratio (the one whose method you are executing) by that ratio (the one you received as a parameter). Recall that you can multiply a ratio by another by multiplying their numerators to find the new numerator, and their denominators to find the new denominator. (5 points) - Complete Challenge Activity 9.2.2 in J+DS zyBook. (4 points)
- Complete Challenge Activity 9.5.1 in J+DS zyBook. (4 points)

Terminology

- classes
- fields, instance variables
- methods, member methods
- object-oriented programming
- objects
- encapsulate
- constructor
- accessor method
- mutator method

Examples