teaching machines

CS 145 Lab 10 – Objects and ArrayList

November 26, 2016 by . Filed under cs145, fall 2016, labs.

Welcome to lab 10!

If you have checkpoints from the last lab to show your instructor or TA, do so immediately. No credit will be given if you have not already completed the work, nor will credit be given after the first 10 minutes of this lab.

In this lab you will create our own custom data types. We will model objects’ state and behaviors using classes in Java.

Checkpoint 1

Person A types.

Solve the following problems on Practice-It!:

Checkpoint 2

Person B types.

Write a class RoundRobinList that can be used to repeatedly and fairly cycle through a list of people or things. For example, if you create a list and add to it "apple", "banana", and "carbonite", you’ll generate the following sequence when you call get 8 times:

carbonite
banana
apple
carbonite
banana
apple
carbonite
banana

Include the following:

In class RoundRobinTest, write a main method that constructs an instance of RoundRobinList, adds some elements, and cycles through it a few times. Print each element as you retrieve it.