-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.h
More file actions
80 lines (62 loc) · 1.42 KB
/
command.h
File metadata and controls
80 lines (62 loc) · 1.42 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
#ifndef command_h
#define command_h
#include "composite.h"
class Command {
protected:
Base* root;
public:
Command() {};
double execute() {
return this->root->evaluate();
}
Base* get_root() {
return this->root;
}
};
class OpCommand : public Command {
//OpCommand Code Here
public:
OpCommand() : Command() {};
OpCommand(int val) {
this->root = new Op(val);
}
double execute() {
return this->root->evaluate();
}
};
class AddCommand : public Command {
//AddCommand Code Here
public:
AddCommand() : Command() {};
AddCommand(Command* cmd, int val) {
Base* tmp = new Op(val);
this->root = new Add(cmd->get_root(),tmp);
}
};
class SubCommand : public Command {
//SubCommand Code Here
public:
SubCommand() : Command() {}
SubCommand(Command* cmd, int val) {
Base* tmp = new Op(val);
this->root = new Sub(cmd->get_root(),tmp);
}
};
class MultCommand : public Command {
//MultCommand Code Here
public:
MultCommand() : Command() {}
MultCommand(Command* cmd,int val) {
Base* tmp = new Op(val);
this->root = new Mult(cmd->get_root(),tmp);
}
};
class SqrCommand : public Command {
//SqrCommand Code Here
public:
SqrCommand() : Command() {}
SqrCommand(Command* cmd) {
this->root = new Sqr(cmd->get_root());
}
};
#endif //__COMMAND_CLASS__