-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
48 lines (35 loc) · 1.05 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// main.cpp
// Cartesian Product of Sets
//
// Created by Samuel Zaldivar on 2/8/20.
// Copyright © 2020 Samuel Zaldivar. All rights reserved.
//
#include <iostream>
#include <string>
#include "Element.h"
#include "Set.h"
using namespace std;
void enterSet(string, Set*);
int main(){
Set *setA = new Set("A");
Set *setB = new Set("B");
cout << "Press [ENTER] after each element." << endl << "To end press [ENTER] to a blank element." << endl;
enterSet(setA->name, setA);
enterSet(setB->name, setB);
string cartesianProduct = setA->getCartesianProduct(setB);
cout << endl << cartesianProduct << endl << endl;
}
void enterSet(string setName, Set *set){
string element = "";
cout << endl << "Enter elements for Set " << setName << "." << endl;
cout << endl << "Set " << setName << ": " << endl;
while(true){
getline(cin, element);
if(element.empty())
break;
else
set->addElement(element);
}
set->printSet();
}