teaching machines

CS 148: Lab 10 – Arrays

November 15, 2017 by . Filed under cs1, cs148, fall 2017, 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 work with data that has been collected into arrays. Arrays let us number our data, making it easy to loop through the collection or associate data with the natural numbers.

Checkpoint 1

Person A types.

Suppose you have an array of 10 String names. You want to select 5 of them for a drug test. Repeat subjects are not allowed. Write a method pick5 that accepts an array containing the 10 names as a parameter and prints 5 unique names drawn at random. Do not use ArrayList.

Checkpoint 2

Person B types.

Watch this clip of Link’s Awakening, in which the player solves a puzzle by filling in the floor. Also, watch a few moments of this clip of Machinarium, a beautifully illustrated point-and-click puzzle game. Write a program that lets the user trace out a space-filling path a bit like you see in the clips. Our path will be more like Machinariums—we’ll only let the player change direction when the current segment comes to a halt.

Let’s break this down into a few steps:

Add some obstacles into your board and invite a classmate to have a go! But be careful. Not all board configurations are solvable.