Assignment 1

CS203
Spring 2013
Assigned: Fri, Feb 1
Due: Fri, Feb 8

Summary

Implement and test the FSet ADT that is specified below. 1)

Important:
Read this entire page before you begin.
Read this entire page before you begin.
Read this entire page before you begin.

Goals

General Guidelines

Your Java files should begin with a block comment that lists

  1. Your name.
  2. CS203 - Spring 2013
  3. Lab 1 / Assignment 1
  4. Any remarks that you wish to make to me.

Part of your grade will depend on the quality and correctness of your code, part will depend on the readability of your code (comments and indentation), and part will depend on how well you follow the procedure below for submitting your work. Following the Design Recipe (see sidebar) for each method you implement is strongly recommended.

Description

Your assignment is to develop and test the Java code that implements the FSet specification below. Your project will consist of three files. I’m providing you (below) with the main class for this project (Assign1.java). You will implement: FSet.java and Examples.

Specification of the FSet ADT

FSet is an immutable abstract data type whose values represent finite sets with elements of type Double.

The FSet ADT shall be implemented in Java, and will be tested using the version of Java installed on the Linux workstations in our labs. The code for this implementation shall be in the default package, and shall define a public class named FSet. The operations of the FSet class shall be provided by the following public methods of the FSet class:

Signatures

Static methods:

    emptySet  :                                 ->  FSet
    size      : FSet                            ->  int
    add       : FSet x Double                   ->  FSet
    remove    : FSet x Double                   ->  FSet
    isEmpty   : FSet                            ->  boolean
    contains  : FSet x Double                   ->  boolean
    isSubset  : FSet x FSet                     ->  boolean
    union     : FSet x FSet                     ->  FSet
    intersect : FSet x FSet                     ->  FSet

Dynamic methods (for which the receiver is an FSet):

    toString  :                                 ->  String
    equals    :  Object                         ->  boolean
    hashCode  :                                 ->  int

Restrictions:

  Null arguments may not be passed to any of the above methods
  except for equals(Object).

Main class Implementation Notes

Here is my implementation of the main class for this assignment (Assign1.java):

/*
 * CS203
 * Spring 2013
 * Marc Smith
 * Assign 1 (and lab 2)
 * Solution
 */
 
import tester.Tester;
 
/**
 * Main class for Assignment 1
 * Kicks off the Tester which runs the tests in Examples class
 */
public class Assign1 {
    public static void main(String[] args) {
        Tester.runFullReport( new Examples() );
    }
}

FSet Implementation Notes

Examples class Implementation Notes

Tester Library Notes

You need to import the tester library to compile and run your tests. There are two ways to do this, depending on whether you are running your your project from Netbeans or the command line:

From Netbeans:

From the command line:

compile your program using:
javac -cp .:/home/cs203/jars/tester.jar *.java

run your program using:
java -cp .:/home/cs203/jars/tester.jar Assign1

Submission Details

To submit what you have at the end of lab:
$ submit203 lab2 <FSet-root-dir>

When you’re ready to submit the assignment:
$ submit203 assign1 <FSet-root-dir>

1) this assignment has been adapted for our use with permission by Viera Proulx