teaching machines

CS 148 Lab 10 – Objects and ArrayList

November 17, 2019 by . Filed under cs1, cs148, fall 2019, 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. Create a labs.lab10 package.

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 the list’s get method 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 make several complete cycles through it. Print each element as you retrieve it.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *