-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(infinite number): class to make basic calculs
- Loading branch information
1 parent
b4dbdb6
commit a3ab920
Showing
5 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// Created by Pierre-Alexandre Delgado on 28/02/2024. | ||
// | ||
|
||
#include "InfiniteNumber.h" | ||
|
||
#include <iostream> | ||
#include <map> | ||
|
||
namespace Operations { | ||
|
||
std::string InfiniteNumber::addition(std::string &a, std::string &b) { | ||
return ""; | ||
} | ||
|
||
std::string InfiniteNumber::substraction(std::string &a, std::string &b) { | ||
return ""; | ||
} | ||
|
||
std::string InfiniteNumber::division(std::string &a, std::string &b) { | ||
return ""; | ||
} | ||
|
||
std::string InfiniteNumber::modulo(std::string &a, std::string &b) { | ||
return ""; | ||
} | ||
|
||
std::string InfiniteNumber::multiplication(std::string &a, std::string &b) { | ||
return ""; | ||
} | ||
|
||
|
||
std::string InfiniteNumber::makeOperation(std::string &operation) { | ||
std::string a; | ||
std::string b; | ||
std::string sign; | ||
|
||
for (unsigned int i = operation[0] == '+' || operation[0] == '-' ? 1 : 0; i < operation.size(); ++i) { | ||
if (operation[i] == '+' || operation[i] == '-' || operation[i] == '*' || operation[i] == '/' || operation[i] == '%') { | ||
a = operation.substr(0, i); | ||
b = operation.substr(i + 1, operation.size() - 1); | ||
sign = operation.substr(i, 1); | ||
break; | ||
} | ||
} | ||
return this->addition(a, b); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// Created by Pierre-Alexandre Delgado on 28/02/2024. | ||
// | ||
|
||
#ifndef INFINITENUMBER_H | ||
#define INFINITENUMBER_H | ||
|
||
#include <IOperations.hpp> | ||
|
||
namespace Operations { | ||
|
||
class InfiniteNumber : public IOperations { | ||
public: | ||
std::string makeOperation(std::string &operation); | ||
|
||
private: | ||
std::string addition(std::string &a, std::string &b); | ||
std::string substraction(std::string &a, std::string &b); | ||
std::string multiplication(std::string &a, std::string &b); | ||
std::string division(std::string &a, std::string &b); | ||
std::string modulo(std::string &a, std::string &b); | ||
}; | ||
|
||
} // Operation | ||
|
||
|
||
|
||
#endif //INFINITENUMBER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters