diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-22 14:17:03 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-22 14:17:03 +0200 |
| commit | ac652bb6fb45099008e862e3ced650299dc3ebb7 (patch) | |
| tree | 12fb1c902c271fbeac41c4ee416cf1cd76b16fd7 /cpp/examples | |
| parent | 71e104d84b3538e15f27df79b151e6b49cbad1eb (diff) | |
| parent | e391c4624055138f075c0e5772ccaf8ede094b5a (diff) | |
| download | nissy-core-ac652bb6fb45099008e862e3ced650299dc3ebb7.tar.gz nissy-core-ac652bb6fb45099008e862e3ced650299dc3ebb7.zip | |
Merge branch 'master' into extend_moves
Diffstat (limited to 'cpp/examples')
| -rw-r--r-- | cpp/examples/move.cpp | 17 | ||||
| -rw-r--r-- | cpp/examples/move_convert.cpp | 24 |
2 files changed, 17 insertions, 24 deletions
diff --git a/cpp/examples/move.cpp b/cpp/examples/move.cpp new file mode 100644 index 0000000..970a65d --- /dev/null +++ b/cpp/examples/move.cpp | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | /* A simple example showing how to move a cube and print it in H48 format. */ | ||
| 2 | |||
| 3 | #include "../nissy.h" | ||
| 4 | #include <iostream> | ||
| 5 | |||
| 6 | int main() { | ||
| 7 | nissy::cube c; | ||
| 8 | if (!c.move("R' U' F").ok()) { | ||
| 9 | std::cout << "Error moving the cube!" << std::endl; | ||
| 10 | return 1; | ||
| 11 | } | ||
| 12 | |||
| 13 | auto str = c.to_string(); | ||
| 14 | std::cout << "Cube after R' U' F:" << std::endl << str << std::endl; | ||
| 15 | |||
| 16 | return 0; | ||
| 17 | } | ||
diff --git a/cpp/examples/move_convert.cpp b/cpp/examples/move_convert.cpp deleted file mode 100644 index 11398df..0000000 --- a/cpp/examples/move_convert.cpp +++ /dev/null | |||
| @@ -1,24 +0,0 @@ | |||
| 1 | /* A simple example showing how to move a cube and print it in H48 format. */ | ||
| 2 | |||
| 3 | #include "../nissy.h" | ||
| 4 | #include <iostream> | ||
| 5 | |||
| 6 | int main() { | ||
| 7 | nissy::cube c; | ||
| 8 | if (!c.move("R' U' F").ok()) { | ||
| 9 | std::cout << "Error moving the cube!" << std::endl; | ||
| 10 | return 1; | ||
| 11 | } | ||
| 12 | |||
| 13 | auto string_or_error = c.to_string("H48"); | ||
| 14 | if (std::holds_alternative<nissy::error>(string_or_error)) { | ||
| 15 | std::cout << "Error converting cube!" << std::endl; | ||
| 16 | return 1; | ||
| 17 | } | ||
| 18 | |||
| 19 | auto str = std::get<std::string>(string_or_error); | ||
| 20 | std::cout << "Cube in H48 format after R' U' F:" << std::endl | ||
| 21 | << str << std::endl; | ||
| 22 | |||
| 23 | return 0; | ||
| 24 | } | ||
