/
NobracketString.cpp
790 lines (654 loc) · 22 KB
/
NobracketString.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
#include "NobracketString.h"
#include "Logs.h"
#include "Integers.h"
#include "nthRoot.h"
#include "Pi.h"
#include "Exponential.h"
#include "Exponent.h"
#include "Fraction.h"
/*
update (4/8):
1. This class will expected to receive a string of expression, (no brackets);
and seperate them into two vectors. one stores value, the other store op;
2.it will simplify each type of the value by creating a new type object.
3. and it will recieve a new simplfy string from the correspoinding class.
4. and then it will do the operator, check vector op first, if it contains'*', do the * operations, and then if it only has +,-, check vector somnumbs and find the same type and do the corresponding calculation.
5. after checking all the types throught the type vectors, and we do all we can to calculater, the answer = somenumb[0]+type[0]+somenumb[1]+type[1]+....
5. still working on it. =)
*/
/*
update(4/9)
1. add findOpMutiPosition(), calculating() functions to the class
example:
log_3:4 + 2/3 * 7 + 9
somenumb op type index
log_3:4 + log 0
2/3 * frac 1
7 + int 2
9 int 3
2. in this case, first we need to find * , so the findOpMutiPosition() will handle this steps, if it has "*", it will return the index position of *,
if it does not have, return -1;
3. and then the calculating () function will assign the calculation to each operator.
#it check the return value of the findOpMutiPosition(),
base on the return value, if it's a -1, it will compare type vector, one by one, if it has same type, or(frac, and int), depends on the op vector, if will call the corresponding operator function.
*/
/*
* THIS CODE only can do Logs calculation because I don't have anyother type of class I can test.
* Integer,Pi,E,NthRoot,Fraction class if you can provide any of these class will be great.
* I will try to work on Integer class and then I can test integer and Logs type together.
*
*/
NobracketString::NobracketString(string expression) {
// TODO Auto-generated constructor stub
this->expression=expression;
separateString();
simplifynumbers();
calculating();
formFinalAnser();
}
NobracketString::~NobracketString() {
// TODO Auto-generated destructor stub
}
void NobracketString:: separateString(){
//separateString and store them in the vector somenumbs
string temp;
bool hasTwoOp=false;
string checkop ="";
for(int i=0;i<expression.length();i++){
if(expression[i]=='+'||expression[i]=='*'){
op.push_back(expression[i]);
somenumbs.push_back(temp);
temp = "";
}
else if((expression[i]=='^'||expression[i]=='/')&& !hasTwoOp){
if(expression[i]=='^'){ //if k is ^, keep it to tem[;]
for(int k=i;k<expression.length();k++){ //check after ^ if it has / or not;
//check for if it has / or not.
if(expression[k]=='/'){
hasTwoOp=true;
}else{
}
}
}
else{ //if k is /
for(int k=i;k<expression.length();k++){ //check after ^ ifit has / or not;
if(expression[k]=='^'){
hasTwoOp=true;
}else{
}
}
}
}
if(hasTwoOp){
if(expression[i]=='/'){ //if has / record,
temp +=expression[i];
}else{
temp +=expression[i];
}
}
else if(!hasTwoOp&&expression[i]!='+'&&expression[i]!='*'){
temp +=expression[i];
}
}
somenumbs.push_back(temp);
}
void NobracketString::simplifynumbers(){ //maybe need to delete the object I create here.
for(int i = 0; i<somenumbs.size();i++){
string tempnumb = somenumbs[i];
if(tempnumb.find("^")<100 && tempnumb.find("log")>100){ /////this lines needs to go into
Exponent* power = new Exponent(somenumbs[i]);
somenumbs[i]=power->getAnswer();
if(power->canSimplifyToInt()){
type.push_back("int");
}else if(power->canSimplifyToFrac()){
type.push_back("frac");
}else{
type.push_back("exp");
}
}
else if(tempnumb.find("rt")<100){
nthRoot* power = new nthRoot(somenumbs[i]);
//will do the simplification in constructor.
somenumbs[i]=power->getSimp(); //get a string type
if(power->canSimplifytoInt()){
type.push_back("int");
}
else if(power->canSimpifytoFrac()){
type.push_back("frac");
}else{
type.push_back("root");
}
}
else if(tempnumb.find("/")<100 && tempnumb.find("p")>100){ //im each value, if it contains /,
Fraction* fra = new Fraction(somenumbs[i]);
somenumbs[i]=fra->getAnswer(); //change the vector number to the simplify number.
tempnumb = fra->getAnswer();
if(fra->canSimplifytoInteger()) { //if it simplifies to int
type.push_back("int"); } // put "int" in the vector type;
else{
type.push_back("frac");
}
}
else if(tempnumb.find("log")<100){
Logs* lg = new Logs(somenumbs[i]);
somenumbs[i]=lg->getSimplify();
if(somenumbs[i]==expression){ //if user enter a log only and it cannot be simplify
//
expression = lg->FinalSplit(); //try split it;
if(somenumbs[i]==expression){
//if the log cannot be split, do nothing.
}else{
somenumbs.erase(somenumbs.begin());
type.clear();
separateString();
simplifynumbers();
}
}
if(lg->canSimplifytoInt()){ //check if it can be simplified
type.push_back("int");
//if it simplifies to int, put "int" to vector type;
}
else if(lg->canSimplifytoFra()){
type.push_back("frac");
//else if it simplifies to fraction, put "fra" to vector type;
}else{
type.push_back("log"); ////cout<<"in the log to log here"<<endl;
}
}
else if(tempnumb.find("Pi")<100||tempnumb.find("pi")<100){
type.push_back("pi");
}
else if(tempnumb.find("e")<100){
type.push_back("e");
}else{
type.push_back("int");
}
}
}
string NobracketString::getFinalAnswer(){
return FiAnswer;
}
void NobracketString::add(string Anumb, string Atype, string Bnumb, string Btype){ //does not need to handle differen type here only handel same type or (fraction and integer)
if(Atype==Btype){ //if they are the same type;
if(Atype == "frac")
{
Fraction* fra = new Fraction(Anumb);
Fraction* frb = new Fraction(Bnumb);
fra->Addition(*frb);
opAnswer = fra->getAnswer();
isReturnOneNumb = true;
//same type fraction should always return one numb
//delete[] fra; // here may need to delete the object.
}
else if(Atype == "int")
{
Integers* intnumbA = new Integers(Anumb);
Integers* intnumbB = new Integers(Bnumb);
intnumbA->Add(*intnumbB);
opAnswer = intnumbA->getAnswer();
//// //delete[] intnumb;
isReturnOneNumb = true;
}
else if(Atype=="log")
{
Logs* lgA = new Logs(Anumb);
Logs* lgB = new Logs(Bnumb);
lgA->add(*lgB);
opAnswer = lgA->getAnswer();
//delete[] lg;
if(opAnswer.find("+")<100) //if the opanswer string contains "+", means it return a complex expression
isReturnOneNumb = false;
else
isReturnOneNumb = true;
}
else if(Atype=="root")
{
nthRoot* nthNumb = new nthRoot(Anumb);
nthRoot* B = new nthRoot(Bnumb);
nthNumb->add(*B);
opAnswer = nthNumb->getAns();
if(opAnswer.find("+")<100) //if the opanswer string contains "+", means it return a complex expression
isReturnOneNumb = false;
else
isReturnOneNumb = true;
}//it is handled in the calculating()
else if(Atype=="pi"){
//
isReturnOneNumb = true;
}
else if(Atype=="e"){
Exponential* p = new Exponential(Anumb);
p->Add(*p);
opAnswer = p->getAnswer();
isReturnOneNumb = true;
}else if(Atype=="exp"){
}
}else{ //if not the same type
if((Atype=="root"&&Btype=="int")||(Btype=="int"&&Atype=="root")){
nthRoot* nthNumb = new nthRoot(Anumb);
nthRoot* B = new nthRoot(Bnumb);
nthNumb->add(*B);
opAnswer = nthNumb->getAns();
if(opAnswer.find("*")<100) //if the opanswer string contains "+", means it return a complex expression
isReturnOneNumb = true;
else
isReturnOneNumb = true;
}
}
}
void NobracketString::substract(string Anumb,string Atype, string Bnumb, string Btype){ //does not need to handle differen type here only handel same type or (fraction and integer)
isReturnOneNumb = false;
if(Atype==Btype){ //if they are the same type;
if(Atype == "frac")
{
Fraction* fra = new Fraction(Anumb);
Fraction* frb = new Fraction(Bnumb);
//fra->Subtraction(*frb);
opAnswer = fra->getAnswer();
isReturnOneNumb = true; // here may need to delete the object.
}
else if(Atype == "int")
{
Integers* intnumbA = new Integers(Anumb);
Integers* intnumbB = new Integers(Bnumb);
intnumbA->Subtract(*intnumbB);
opAnswer = intnumbA->getAnswer();
//// //delete[] intnumb;
isReturnOneNumb = true;
}
else if(Atype=="log")
{
Logs* lgA = new Logs(Anumb);
Logs* lgB = new Logs(Bnumb);
lgA->substract(*lgB);
opAnswer = lgA->getAnswer();
//delete[] lg;
if(opAnswer.find("-")<100)
{ //if the opanswer string contains "+", means it return a complex expression
isReturnOneNumb = false;
}
else
isReturnOneNumb = true;
}
else if(Atype=="root")
{
nthRoot* nthNumb = new nthRoot(Anumb);
nthRoot* B = new nthRoot(Bnumb);
nthNumb->subtract(*B);
opAnswer = nthNumb->getAns();
if(opAnswer.find("-")<100) //if the opanswer string contains "+", means it return a complex expression
isReturnOneNumb = false;
else
isReturnOneNumb = true;
}//it is handled in the calculating()
else if(Atype=="pi"){
// Pi* p = new Pi(Anumb);
// p->Subtract(*p);
// opAnswer = p->getAnswer();
isReturnOneNumb = true;
}
else if(Atype=="e"){
Exponential* p = new Exponential(Anumb);
Exponential* b = new Exponential(Bnumb);
//p->Subtract(*b);
opAnswer = p->getAnswer();
isReturnOneNumb = true;
}
else if(Atype=="exp"){
Exponent* power = new Exponent(Anumb);
Exponent* b = new Exponent(Bnumb);
power->subtract(*b);
opAnswer = power->getAnswer();
if(opAnswer.find("-")<100) //if the opanswer string contains "+", means it return a complex expression
isReturnOneNumb = false;
else
isReturnOneNumb = true;
}
}else{ //if not the same type
}
}
void NobracketString::divide(string Anumb,string Atype, string Bnumb, string Btype){ //need to handle different types calculation, basicly differen type just return as it is.
isReturnOneNumb = false;
if(Atype==Btype){ //if they are the same type;
if(Atype == "frac")
{
Fraction* fra = new Fraction(Anumb);
Fraction* frb = new Fraction(Bnumb);
fra->Division(*frb);
opAnswer = fra->getAnswer();
isReturnOneNumb = true; // here may need to delete the object.
}
else if(Atype == "int")
{
Integers* intnumbA = new Integers(Anumb);
Integers* intnumbB = new Integers(Bnumb);
intnumbA->Divide(*intnumbB);
opAnswer = intnumbA->getAnswer(); //!!!!!here type has to be a "frac"!!!!!
//// //delete[] intnumb;
// if(opAnswer.find("/")<100)
// isReturnOneNumb = false;
// else
isReturnOneNumb = true;
}
else if(Atype=="log")
{
Logs* lgA = new Logs(Anumb);
Logs* lgB = new Logs(Bnumb);
lgA->divide(*lgB);
opAnswer = lgA->getAnswer();
//delete[] lg;
if(opAnswer.find("/")<100){ //if the opanswer string contains "+", means it return a complex expression
isReturnOneNumb = false;}
else
isReturnOneNumb = true;
}
else if(Atype=="root")
{
nthRoot* nthNumb = new nthRoot(Anumb);
nthRoot* B = new nthRoot(Bnumb);
nthNumb->divide(*B);
opAnswer = nthNumb->getAns();
if(opAnswer.find("/")<100) //if the opanswer string contains "+", means it return a complex expression
isReturnOneNumb = false;
else
isReturnOneNumb = true;
}//it is handled in the calculating()
else if(Atype=="pi"){
// Pi* p = new Pi(Anumb);
// p->Divide(*p);
// opAnswer = p->getAnswer();
isReturnOneNumb = true;
}
else if(Atype=="e"){
Exponential* p = new Exponential(Anumb);
Exponential* b = new Exponential(Bnumb);
p->Divide(*b);
opAnswer = p->getAnswer();
isReturnOneNumb = true;
}else if(Atype=="exp"){
Exponent* power = new Exponent(Anumb);
Exponent* b = new Exponent(Bnumb);
power->divide(*b);
opAnswer = power->getAnswer();
if(opAnswer.find("-")<100) //if the opanswer string contains "+", means it return a complex expression
isReturnOneNumb = false;
else
isReturnOneNumb = true;
}
}else{ //if not the same type
}
}
void NobracketString::Multip(string Anumb,string Atype, string Bnumb, string Btype){
isReturnOneNumb = false;
if(Atype==Btype){ //if they are the same type;
if(Atype == "frac")
{
Fraction* fra = new Fraction(Anumb);
Fraction* frb = new Fraction(Bnumb);
fra->Multiplication(*frb);
opAnswer = fra->getAnswer();
isReturnOneNumb = true; // here may need to delete the object.
}
else if(Atype == "int")
{
Integers* intnumbA = new Integers(Anumb);
Integers* intnumbB = new Integers(Bnumb);
intnumbA->Multiply(*intnumbB);
opAnswer = intnumbA->getAnswer();
//// //delete[] intnumb;
isReturnOneNumb = true;
}
else if(Atype=="log")
{
Logs* lgA = new Logs(Anumb);
Logs* lgB = new Logs(Bnumb);
lgA->Multip(*lgB);
opAnswer = lgA->getAnswer();
//delete[] lg;
if(opAnswer.find("*")<100) //if the opanswer string contains "+", means it return a complex expression
isReturnOneNumb = false;
else
isReturnOneNumb = true;
}
else if(Atype=="root")
{
nthRoot* nthNumb = new nthRoot(Anumb);
nthRoot* B = new nthRoot(Bnumb);
nthNumb->multiply(*B);
opAnswer = nthNumb->getAns();
if(opAnswer.find("*")<100) //if the opanswer string contains "+", means it return a complex expression
isReturnOneNumb = false;
else
isReturnOneNumb = true;
}//it is handled in the calculating()
else if(Atype=="pi"){
// Pi* p = new Pi(Anumb);
// p->Multiply(*p);
// opAnswer = p->getAnswer();
isReturnOneNumb = true;
}
else if(Atype=="e"){
Exponential* p = new Exponential(Anumb);
p->Multiply(*p);
opAnswer = p->getAnswer();
isReturnOneNumb = true;
}else if(Atype=="exp"){
Exponent* power = new Exponent(Anumb);
Exponent* b = new Exponent(Bnumb);
power->multiply(*b);
opAnswer = power->getAnswer();
if(opAnswer.find("-")<100) //if the opanswer string contains "+", means it return a complex expression
isReturnOneNumb = false;
else
isReturnOneNumb = true;
}
}
else{
if((Atype=="frac"&&Btype=="int")||(Btype=="frac"&&Atype=="int")){ //if not the same type
Fraction* fra = new Fraction(Anumb);
Fraction* frb = new Fraction(Bnumb);
fra->Multiplication(*frb);
opAnswer = fra->getAnswer();
isReturnOneNumb = true;
}else if((Atype=="int"&&Btype=="root")||(Btype=="int"&&Atype=="root")){
nthRoot* nthNumb = new nthRoot(Anumb);
nthRoot* B = new nthRoot(Bnumb);
nthNumb->multiply(*B);
opAnswer = nthNumb->getAns();
// if(opAnswer.find("*")<100) //if the opanswer string contains "+", means it return a complex expression
// isReturnOneNumb = true;
// else
isReturnOneNumb = true;
}
else{
isReturnOneNumb=false;
}
}
}
void NobracketString::calculating(){
bool havesametype=false;
//check for mutipositio
int temporarySize=0;
if(op.size()==0){
}else{
for(int i = 0;i<=op.size();++i){ //check if op contains '*'
if(temporarySize != op.size()){
i = 0;
}
temporarySize= op.size();
if(op[i]=='/'){
if(i==0){
divide(somenumbs[0],type[0],somenumbs[1],type[1]);
if(isReturnOneNumb){ //if the answer == is return one value example: log_3:4;
somenumbs[i]=opAnswer; //set the element i to the opAnser,
somenumbs.erase(somenumbs.begin()+1); //erase the second element
op.erase(op.begin()); //erase the '*'
}else{
////cout<<"the '*' sign in the index 0 and the answer return more then one value"<<endl;
}
}else{
divide(somenumbs[i],type[i],somenumbs[i+1],type[i+1]);
if(isReturnOneNumb){ //if the answer == is return one value example: log_3:4;
somenumbs[i]=opAnswer; //set the element i to the opAnser,
somenumbs.erase(somenumbs.begin()+(i+1)); //erase the second element
op.erase(op.begin()+(i)); //erase the '*'
// cout<<"the mutip() get answer is now "<<somenumbs[i]<<endl;
// cout<<"im in the calculating function delect '*' sign DOES NOT in the index 0"<<endl;
}
else{
}
}
if(op[i]=='*'){
if(i==0){
Multip(somenumbs[0],type[0],somenumbs[1],type[1]); //do the mulip()
if(isReturnOneNumb){ //if the answer == is return one value example: log_3:4;
somenumbs[i]=opAnswer; //set the element i to the opAnser,
somenumbs.erase(somenumbs.begin()+1); //erase the second element
op.erase(op.begin()); //erase the '*'
//
}
/*
* for 3*sqrt:3+7*sqrt:3 this case;
*/
else{
//cout<<"the '*' sign in the index 0 and the answer return more then one value"<<endl;
} // if the answer return more then one value, example 5*log_3:4;
// somenumbs[i]=opAnswer;
// somenumbs.erase(somenumbs.begin()+1); //erase the second element
// op.erase(op.begin()); //do the mulitify everything as it is.
}
else{
//cout<<"do the mulitify."<<endl;
Multip(somenumbs[i],type[i],somenumbs[i+1],type[i+1]);
if(isReturnOneNumb){ //if the answer == is return one value example: log_3:4;
somenumbs[i]=opAnswer; //set the element i to the opAnser,
somenumbs.erase(somenumbs.begin()+(i+1)); //erase the second element
op.erase(op.begin()+(i)); //erase the '*'
//
}
else{} // if the answer return more then one value, example 5*log_3:4;
//keep everything as it is.
}
}
else{} //if(op[i]!='*', do nothing;
//if(temporarySize != op.size()){
// i = 0;
//}
} //end of checking '*'
}
for(int i=0;type.size()-1>=somenumbs.size();i++){
type.pop_back();
}
int tempSize=0;
for(int i=0;i<op.size();i++){ //start to check if they have the same type; ad do the calculation
for(int j=i+1;j<op.size()+1;j++)
{
tempSize=op.size();
if((type[i]==type[j]&&op[j]=='*')||(type[i]==type[j]&&op[i]=='*')){ //if the op is a *, skip
//do nothing;
}
else if(type[i]==type[j]&&op[j-1]!='*'&&op[j-1]!='*'){ //if it has same type, and op does not have *,check for operator
havesametype = true;
if(op[j-1]=='+')
{ //only have two case +,-
add(somenumbs[j],type[j],somenumbs[i],type[i]);
if(isReturnOneNumb)
{
somenumbs[i]=opAnswer;
if(somenumbs.size()==2&&type.size()==2&&type[1]!=type[0])//set the element i to the opAnser,
{
isReturnOneNumb=false;
havesametype = false;
}else{
somenumbs.erase(somenumbs.begin()+(j)); //erase the second element
type.erase(type.begin()+j);
op.erase(op.begin()+(j-1)); //erase the op
}
}
else
{
//don't change anything.
}
// here need to do something with vectors somenumb and type
// 3 + 7 = 10, 10 will replace 3 in somenumb vector and delete 7 and + from somenumb and type;
// log_3:8 + log_3:7 will return as it is, so the vectors does not change, keep as it is.
}
else //containts "-"l
{
substract(somenumbs[j],type[j],somenumbs[i],type[i]);
if(isReturnOneNumb)
{
somenumbs[i]=opAnswer; //set the element i to the opAnser,
somenumbs.erase(somenumbs.begin()+(j)); //erase the second element
op.erase(op.begin()+(j-1)); //erase the op
}
else
{
//don't change anything.
}
}
}
else if((type[i]=="frac"&&type[j]=="int") || (type[j]=="frac"&&type[i]=="int"))
{
// handle one numb is fraction, one numb is integer
havesametype =true;
if(op[j-1]=='+')
{ //only have two case +,-
add(somenumbs[j],"frac",somenumbs[i],"frac");
if(isReturnOneNumb)
{
somenumbs[i]=opAnswer; //set the element i to the opAnser,
somenumbs.erase(somenumbs.begin()+(j)); //erase the second element
op.erase(op.begin()+(j-1)); //erase the op
}
else
{
//don't change anything.
}
}
else
{
substract(somenumbs[j],"frac",somenumbs[i],"frac");
if(isReturnOneNumb)
{
somenumbs[i]=opAnswer; //set the element i to the opAnser,
somenumbs.erase(somenumbs.begin()+(j)); //erase the second element
op.erase(op.begin()+(j-1)); //erase the op
}
else
{
//don't change anything.
}
}
} //check continue comparing the next type[i+1];
if(tempSize != op.size()){
j=0;
}
//after loop if we cannot find the same type;
}//end of the int j loop
// //cout<<"end check for type here"<<j<<endl;
}//end of the int i loop
}
}
void NobracketString::formFinalAnser(){
int i = 0;
if(op.size()==0){
FiAnswer += somenumbs[0];
}
else{
for(i;i<op.size();i++){
FiAnswer += (somenumbs[i]+op[i]);
}
FiAnswer += somenumbs[i];
}
}
bool NobracketString::ansIsComplex(){
if(somenumbs.size()==1){
//isnt complex
return false;
}
else{
//is complex
return true;
}
}