forked from AlphaMistral/Expression-Calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calculation.cpp
83 lines (70 loc) · 1.68 KB
/
Calculation.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
//
// Calculation.cpp
// Numerical Analysis
//
// Created by 于京平 on 16/7/22.
// Copyright © 2016年 于京平. All rights reserved.
//
#include "Calculation.hpp"
CalculationResult :: CalculationResult ()
{
result = 0;
isValid = false;
statusInformation = "";
}
CalculationResult :: CalculationResult (double r, bool v, string s)
{
result = r;
isValid = v;
statusInformation = s;
}
CalculationResult :: CalculationResult (CalculationResult &calc)
{
result = calc.result;
isValid = calc.isValid;
statusInformation = calc.statusInformation;
}
void CalculationResult :: SetAllParams (double r, bool v, string s)
{
result = r;
isValid = v;
statusInformation = s;
}
void CalculationResult :: SetResult (double r)
{
result = r;
}
void CalculationResult :: SetValidity (bool v)
{
isValid = v;
}
void CalculationResult :: SetInformation (string s)
{
statusInformation = s;
}
double CalculationResult :: GetResult ()
{
return result;
}
bool CalculationResult :: GetValidity ()
{
return isValid;
}
string CalculationResult :: GetInformation ()
{
return statusInformation;
}
void CalculationResult :: AttachInformation (string s)
{
statusInformation += s;
}
void CalculationResult :: OutputResult ()
{
cerr << endl << "******The Output Result for the indicated operation is as follows******" << endl;
cerr << "The numerical result is: " << result << endl;
cerr << "The result is ";
if (!isValid) cerr << "in";
cerr << "valid." << endl;
cerr << "The Status Information is: " << statusInformation << endl;
cerr << "******This is the end of the result of the indicated operation******" << endl << endl;
}