-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
159 lines (132 loc) · 3.49 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include <iostream>
#include "Karnaugh_Map.h"
using namespace std;
/*
Author- Nicholas Samaroo
Completed on January 5,2019
Description- This program will give you the numberings for a size 3 Karnaugh Map and
map your specific 1's and d's onto a size 3 map if desired. It will also give you the numberings for size 4 and 5 maps
making it easier to map the 1's and d's yourself.
*/
int main()
{
int user_choice;
cout << "PROGRAM INSTRUCTIONS\n";
cout << "--------------------\n";
cout << "Enter 1 for a SIZE 3 NUMBERED MAP\n";
cout << "Enter 2 for a SIZE 3 map with your specific 1's and d's mapped onto it.\n";
cout << "Enter 3 for a SIZE 4 NUMBERED MAP\n";
cout << "Enter 4 for a SIZE 5 NUMBERED MAP\n";
cin >> user_choice;
cout << endl;
switch(user_choice)
{
case 1:
{
Karnaugh_Map display_three_map;
int row = 2;
int column = 4;
display_three_map.display_map(row,column);
break;
}
case 2:
{
Karnaugh_Map solver;
int row = 2;
int column = 4;
int three_map_ones;
int three_map_ds;
cout << "How many ones are part of your problem?\n";
cin >> three_map_ones;
if(three_map_ones < 0 || three_map_ones > 8)
{
cout << "Your number of 1's must be inbetween 0 and 7 inclusive\n";
break;
}
else if(three_map_ones == 0)
{
cout << "All positions on the map are replaced with d's\n";
break;
}
else
{
char* ones = new char[three_map_ones];
cout << "Please enter the ones associated with your problem.\n";
for(int i = 0; i < three_map_ones;i++)
{
cin >> ones[i];
}
bool one_status = true;
one_status = solver.numones(ones,three_map_ones);
if(one_status == false)
{
cout << "You have entered something other than a 1, please try again\n";
break;
}
delete[] ones;
ones = nullptr;
}
cout << "How many d's are associated with your problem?\n";
cin >> three_map_ds;
if((three_map_ds + three_map_ones) > 8)
{
cout << "The number of d's and 1's combined cannot exceed 8, try again\n";
break;
}
else if((three_map_ds + three_map_ones) < 8)
{
cout << "The number of 1's and d's must add up to 8,as that is the maximum for a three variable k-map\n";
break;
}
else if(three_map_ds == 0)
{
solver.display_map(row,column);
cout << endl;
break;
}
else
{
char* ds = new char[three_map_ds];
cout << "Please enter the d's associated with your problem\n";
for(int j = 0; j < three_map_ds;j++)
{
cin >> ds[j];
}
cout << endl;
bool status = true;
status = solver.numds(ds,three_map_ds);
if(status == false)
{
cout << "In one of your d positions there already exists a 1 or you have entered something other than a d, please verify your numbers and run the program again\n";
break;
}
else
{
solver.display_map(row,column);
}
delete[] ds;
ds = nullptr;
}
break;
}
case 3:
{
Karnaugh_Map display_four_map;
int row = 4;
int column = 4;
display_four_map.display_map(row,column);
break;
}
case 4:
{
Karnaugh_Map display_five_map;
int row = 4;
int column = 8;
display_five_map.display_map(row,column);
break;
}
default:
cout << "Please enter a valid number\n";
break;
}
}