Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions homework/calculate/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.11.0)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(FetchContent)
Expand All @@ -14,7 +14,6 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

# Now simply link against gtest or gtest_main as needed. Eg

project(calculate)
enable_testing()

Expand Down
17 changes: 15 additions & 2 deletions homework/calculate/calculate.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
#pragma once
#include <iostream>
#include <string>

std::string calculate(const std::string& command, int first, int second) {
// TODO: Implement your solution here and return proper value
return "";
if (command == "add") {
return std::to_string(first + second);
} else if (command == "subtract") {
return std::to_string(first - second);
} else if (command == "multiply") {
return std::to_string(first * second);
} else if (command == "divide") {
if (second == 0) {
return "Division by 0";
}
return std::to_string(first / second);
}

return "Invalid data";
}
Loading