-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator.hpp
76 lines (42 loc) · 1.66 KB
/
calculator.hpp
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
#pragma once
#include"button.hpp"
#include<vector>
#include<stack>
#include <windows.h>
#include<sstream>
#include<iomanip>
#include<SFML/Audio.hpp>
#define NUM_BUTTONS 21
const float larg = GetDeviceCaps(GetDC(NULL), HORZRES);
const float alt = GetDeviceCaps(GetDC(NULL), VERTRES);
const std::string title = "Calculator";
namespace Calc{
class Calculator{
sf::Font font;
sf::SoundBuffer buffer[3];
sf::Sound sound;
std::vector<Useful::Button> buttons;
std::vector<std::string> equation;
std::vector<std::string> symbols;
std::string answer;
bool mute;
void draw(sf::RenderWindow& win);
void checkButtonType();
void initializeSymbols();
void drawButtonsChar(sf::RenderWindow& win, Useful::Button button);
void drawText(sf::RenderWindow& win, std::string str, sf::Vector2f pos,int size_, sf::Color clr);
bool isOperator(std::string str);
bool isDigit(const std::string str);
bool isNumber(std::string str);
Useful::Button createButton(sf::Vector2f pos, sf::Vector2f size_, sf::Color color,sf::Color secondaryColor, std::string type);
void calculatorLogic(std::string inf);
void adjustNumbers();
bool infixToPostfix();
bool result();
void calculateResult();
public:
Calculator();
void update(sf::RenderWindow& win, sf::Event& event);
void checkClick(sf::Event& event);
};
}