-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinomial.cpp
More file actions
68 lines (58 loc) · 1.57 KB
/
binomial.cpp
File metadata and controls
68 lines (58 loc) · 1.57 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
#include"binomial.h"
#include<iostream>
Binomial::Binomial(int c, int x , int x_2) : NumberBase("an A (Jackson)")
{
constant = c;
firstPower = x;
secondPower = x_2;
}
Binomial::Binomial(const Binomial& copyBinomial) : NumberBase("an A (Jackson)")
{
constant = copyBinomial.getConstant();
firstPower = copyBinomial.getFirstPower();
secondPower = copyBinomial.getSecondPower();
}
int Binomial::getConstant() const
{
return Binomial::constant;
}
int Binomial::getFirstPower() const
{
return Binomial::firstPower;
}
int Binomial::getSecondPower() const
{
return Binomial::secondPower;
}
Binomial Binomial::operator+(const Binomial& b)
{
int constant = this->getConstant() + b.getConstant();
int firstPower = this->getFirstPower() + b.getFirstPower();
int secondPower = this->getSecondPower() + b.getSecondPower();
return Binomial(constant, firstPower, secondPower);
}
Binomial Binomial::operator*(int x)
{
int constant = this->getConstant() * x;
int firstPower = this->getFirstPower() * x;
int secondPower = this->getSecondPower() * x;
return Binomial(constant, firstPower, secondPower);
}
void Binomial::print()
{
std::cout << this->getConstant() << " + " << this->getFirstPower() << "x + " << this->getSecondPower() << "(x^2)" << std::endl;
}
void Binomial::demo()
{
std::cout << "------------Jackson Paul-------------" << std::endl;
int three = 3;
Binomial bin(6, 7, 8);
Binomial bin2(bin);
Binomial bin3 = bin + bin2;
Binomial bin4 = bin * 3;
bin.print();
bin2.print();
bin3.print();
bin4.print();
std::cout << "------------Jackson Paul-------------" << std::endl;
}