1 Getting Set Up
2 The Lab

Lab 2, CSC 102, ,Spring 2012

1 Getting Set Up

In this lab, you’re going to be designing data representations for various kinds of data, using simple and compound data.

First, create a project called Lab2, and a package called lab2.

Then, create a test class for this lab, called "Lab2", just as you did for the prior lab, by choosing FileNew JUnit Test Case..., and then adding

import org.junit.Test;

import static org.junit.Assert.*;

... to the top of the file, as you did for the last one.

Create a single testX method:

@Test

public static void testX(){

  // nothing here yet.

}

In this lab, you’re not going to be using assertEquals to test methods; instead, you’re simply going to be creating examples of the data that you define.

2 The Lab

Let’s start simple. Suppose I asked you to represent the number of marbles in a jar. You’d probably represent that using an int. For a problem like this, you’d add something like

  int marbles = 9;

... to the testX method, and make sure that the Test button still gives you the green bar.

For each of the following: decide how you’re going to represent the data, define any classes necessary, then create at least two examples of the data by adding declarations to the testX method.

Each class should come with a one-line comment indicating what it represents.

Be sure to re-use earlier definitions whenever it makes sense to do so.

Show me your work when you’re done.