assignment2 - CS 2026 Spring 2010 Assignment 2 2/5/2010...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 2026 Spring 2010 Assignment 2 2/5/2010 Due: 2/12/2010 11:59 PM This assignment will exercise your knowledge of C# features such as enumerators, generics, operator overload, properties, etc. In this assignment, you’ll implement a generic Set<T> class that is parameterized by the type of object it contains. The set will be used as a basic container of objects of type T. Since this is a set, there is only one copy of any object in it. For example: {1,2,2,3} and {1,2,3} are the same set. You should implement the following methods: Set() o The default constructor. Set(IEnumerable<T> e) o A constructor that fills the set with all the elements in some enumerable collection. public static Set<T> operator +(Set<T> lhs, Set<T> rhs) o This operator implements set union: it should return a new set that contains any item contained in either the lhs or the rhs set. public bool Add(T item) o This method adds the input element to the set. It returns true if the element is added to the set, and false if the element is already present in the set.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

assignment2 - CS 2026 Spring 2010 Assignment 2 2/5/2010...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online