From a1a32acad2f4f1646621f2758baf180b6b7354d2 Mon Sep 17 00:00:00 2001 From: szymon Date: Wed, 9 Sep 2026 11:07:49 +0200 Subject: [PATCH 1/4] sum changes --- homework/calculate/CMakeLists.txt | 3 +-- homework/calculate/calculate.hpp | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/homework/calculate/CMakeLists.txt b/homework/calculate/CMakeLists.txt index 087714e7..3fcbf95f 100644 --- a/homework/calculate/CMakeLists.txt +++ b/homework/calculate/CMakeLists.txt @@ -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) @@ -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() diff --git a/homework/calculate/calculate.hpp b/homework/calculate/calculate.hpp index 7a933a25..f8802d15 100644 --- a/homework/calculate/calculate.hpp +++ b/homework/calculate/calculate.hpp @@ -1,7 +1,24 @@ #pragma once #include +#include 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"; } From 83a189cbb697abcbea690caca9c716cb294de4c3 Mon Sep 17 00:00:00 2001 From: szymon Date: Wed, 9 Sep 2026 13:51:50 +0200 Subject: [PATCH 2/4] llvm --- homework/calculate/calculate.hpp | 37 +++++++++++++++----------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/homework/calculate/calculate.hpp b/homework/calculate/calculate.hpp index f8802d15..7025a477 100644 --- a/homework/calculate/calculate.hpp +++ b/homework/calculate/calculate.hpp @@ -1,24 +1,21 @@ #pragma once -#include #include +#include -std::string calculate(const std::string& command, int first, int second) { - // TODO: Implement your solution here and return proper value - 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); +std::string calculate(const std::string &command, int first, int second) { + // TODO: Implement your solution here and return proper value + 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 "Invalid data"; -} + return std::to_string(first / second); + } + + return "Invalid data"; +} \ No newline at end of file From 186fc6481a38399d7921e50410a4bcae2ac4de02 Mon Sep 17 00:00:00 2001 From: szymon Date: Wed, 9 Sep 2026 13:55:28 +0200 Subject: [PATCH 3/4] poprawka --- homework/calculate/calculate.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homework/calculate/calculate.hpp b/homework/calculate/calculate.hpp index 7025a477..814801e7 100644 --- a/homework/calculate/calculate.hpp +++ b/homework/calculate/calculate.hpp @@ -18,4 +18,4 @@ std::string calculate(const std::string &command, int first, int second) { } return "Invalid data"; -} \ No newline at end of file +} From 69813cc59e819e1a591b7396a8ede6c251d9822e Mon Sep 17 00:00:00 2001 From: szymon Date: Wed, 16 Sep 2026 22:31:31 +0200 Subject: [PATCH 4/4] clang tidy --- homework/calculate/calculate.hpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/homework/calculate/calculate.hpp b/homework/calculate/calculate.hpp index 814801e7..85f59493 100644 --- a/homework/calculate/calculate.hpp +++ b/homework/calculate/calculate.hpp @@ -2,20 +2,19 @@ #include #include -std::string calculate(const std::string &command, int first, int second) { - // TODO: Implement your solution here and return proper value - 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"; +std::string calculate(const std::string& command, int first, int second) { + 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 std::to_string(first / second); - } - return "Invalid data"; + return "Invalid data"; }