-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexam.cpp
More file actions
129 lines (110 loc) · 2.48 KB
/
exam.cpp
File metadata and controls
129 lines (110 loc) · 2.48 KB
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
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
const int MAX = 100;
struct Stuck
{
int top;
int list[MAX];
double data;
int count;
Stuck()
{
top = -1;
}
// para insertar (push)
void push(int element)
{
if(fullStuck())
{
throw "its full";
}
top++;
list[top]= element;
}
//para quitar(pop)
int pop()
{
int aux;
if (emptyStuck())
{
throw " its none of the elements can delete";
}
aux =list[top];
top--;
return aux;
}
void clearStuck()
{
top=-1;
}
//operacion de acceso
int topStuck()
{
if(emptyStuck())
{
throw "none of the elements can found";
}
return list[top];
}
// verificacion del estado de la pila
bool emptyStuck()
{
return top ==-1;
}
bool fullStuck()
{
return top == MAX -1;
}
};
enum CalculatorType
{
RPN
};
struct ICalculator
{
int a;
int b;
const char * op;
void eval(int a, int b, const char *op)
{
}
// virtual double create_Calculator(const ICalculator&) const = 0;
};
struct CalculatorFactory :public Stuck
{
ICalculator* create_calculator(CalculatorType tpye)
{
return nullptr;
}
void show()
{
}
};
// struct CalculatorType
// {
// static int RPN();
// };
// struct RPN
// {
// };
int main()
{
CalculatorFactory cf;
ICalculator* calc = cf.create_calculator(CalculatorType::RPN);
// show(calc->eval2 3 +")); // 5
// show(calc->eval("100 12.5 13.7 * -")); // 67.825
// show(calc->eval("5 6 7 8 + - * 5 +")); // 50
// show(calc->eval("6 inc")); // [Error: operator 'inc' unknown]
// show(calc->eval("7 2 max")); // [Error: operator 'max' unknown]
// show(calc->eval("7 *")); // [Error: no operand found for '*']
// show(calc->eval("+")); // [Error: no operand found for '+']
// show(calc->eval("abc")); // [Error: operator 'abc' unknown]
// show(calc->eval("12x6")); // [Error: syntax error]
// calc->add_operator("inc", new IncOperator());
// calc->add_operator("max", new MaxOperator());
// calc->add_operator("sqrt", new SqrtOperator());
// show(calc->eval("10 5 max inc")); // 11
// show(calc->eval("25.8 63 max inc sqrt")); // 8
}