

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Programming Fundamentals II; Subject: Computer Science - CSCI; University: Texas A & M University-Commerce; Term: Fall 2004;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


CSCI 152.2 Program 6 Fall 2004 Due: Wed, 1 Dec Emphasis on: Creating and using a class, Overloading Operator Functions For program 6, you are to revisit program 2 to implement a set as a class. Your private variables will be an array of ints to represent a set and an int to store the number of values currently in the set. You should provide public operations of:
For example, if A and B are two sets of integers defined as A = { 5, 7, 8, 10 } and B = { 3, 9, 10 }, then their union (A + B) is the set { 3, 5, 7, 8, 9, 10 } their intersection (A * B) is the set { 10 } the difference of A and B (A - B) is the set { 5, 7, 8 } the difference of B and A (B - A) is the set { 3, 9 }. Input File File setdata.txt contains an even number of lines of data. Each line represents the values to be assigned to a set. Each line contains up to 25 random positive integers with a space between consecutive integers. The integers are in no particular order, and a particular integer may appear more than once. Example: 4 8 10 2 14 7 10 8 Processing Write a program that repeats the following until end of file:
{ 1, 2, 3 } + { 4, 5, 6 } = { 1, 2, 3, 4, 5, 6 } { 1, 2, 3, 4 } + { 2, 4, 6 } = { 1, 2, 3, 4, 6 } { 1, 2, 3, 4 } * { 2, 4, 6 } = { 2, 4 } { 1, 2, 3 } * { 4, 5, 6 } = { } { 1, 2, 3, 4 } - { 2, 4 } = { 1, 3 } { 2, 4 } - { 1, 2, 3, 4 } = { } { 1, 2, 3, 4 } - { 2, 4, 6 } = { 1, 3 } { 2, 4, 6 } - { 1, 2, 3, 4 } = { 6 } { 1, 2, 3 } - { 4, 5, 6 } = { 1, 2, 3 } { 4, 5, 6 } - { 1, 2, 3 } = { 4, 5, 6 } { 1, 2, 3 } - { 1, 2, 3, 4 } = { } { 1, 2, 3, 4 } - { 1, 2, 3 } = { 4 }