CS 261 Lab E - LetterSet

Due Wed Oct 01 at 3:00pm

Overview

For this lab, you will implement an ADT that represents a "bag of letters". This class will keep track of the number of occurances of each particular letter in the set--so the word "banana" would have three of the letter 'a', one of the letter 'b', and two of the letter 'n'. Your ADT will include methods for checking what items are in the LetterSet, as well as combining LetterSets together.

This assignment will give you a chance to practice working with sets (though you won't be implementing the java.util.Set interface). You'll also be able to practice with performing some mapping operations, though your ADT won't just act as a map.

This lab will be completed in pairs. Partner assignments for this lab can be found on Moodle

Objectives

Necessary Files

You will be creating your new ADT from scratch. However, you may want to download the LetterSetLab.zip file, which contains a "tester" for your LetterSet that you can use to confirm that it works. (Note: you will need to comment out tests for methods that you haven't written yet!)

Background: Characters and Unicode

Java, like all computer programs, stores all data in 0s and 1s. This includes chars, thus the letter 'a' is represented in memory by a series of 0s and 1s. Since those 0s and 1s also can be seen as a binary number (that is, a number in base 2 rather than base 10), each char is directly associated with an int. The number that represents each letter is known as it's Unicode value.

Moreover, you can easily convert a char to its Unicode number by casting it as an int. Thus:

In this way, casting can be seen as a mapping function from char to int! So if you want to, say convert a character into a number (such as for determining its location in an array for this assignment), you can just cast it!

This also means that you can compare letters using < and >, in the manner you'd expect (because their unicode values are compared instead).

Lab Details

You should Read through all of these instructions carefully before you begin!

Your task is to create a new class called LetterSet that will represent a set of letters. Your class should have the following public interface:

You can test your class using the provided tester. However, I recommend you create your own tests (and/or use the debugger!) to make sure that everything works.

Submitting

Make sure both your names are on the LetterSet class. Once you're finished, upload the src code to the LabE submission folder on hedwig. One partner should to upload the code--we will only grade one partner's copy of the program. Make sure you upload your work to the correct folder! The lab is due at the start of class the day after lab.

After you have submitted your solution, log onto Moodle and submit the Lab E Partner Evaluation. Both partners need to submit evaluations.

Grading

This assignment will be graded out of 20 points: