Initial work on calculator program.
This commit is contained in:
20
calculator/Recipe.cpp
Normal file
20
calculator/Recipe.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <exception>
|
||||
#include <format>
|
||||
#include <string>
|
||||
|
||||
#include "Recipe.h"
|
||||
|
||||
std::vector<std::pair<Product, float> > Recipe::Ingredients(float overclock)
|
||||
{
|
||||
if(overclock < 0.0f || overclock > 2.5f)
|
||||
{
|
||||
auto error = std::format("Invalid overclock of {:.2f}%.", (overclock * 100.0f));
|
||||
throw std::invalid_argument(error);
|
||||
}
|
||||
|
||||
std::vector<std::pair<Product, float> > rtn;
|
||||
for(const auto &ingredient : ingredients)
|
||||
rtn.push_back({ingredient.first, ingredient.second * overclock});
|
||||
|
||||
return rtn;
|
||||
}
|
||||
Reference in New Issue
Block a user