From bbd110ebcf4dcf2d13867ee70a5eb2cff32ea8b4 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 5 May 2022 14:43:49 +0300 Subject: Autocommit at 05.05.2022 @ 14:43 --- src/ConsoleInterface/Menu.cpp | 9 ++++----- src/List/List.hpp | 8 +++++--- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/ConsoleInterface/Menu.cpp b/src/ConsoleInterface/Menu.cpp index 190fe42..58477df 100644 --- a/src/ConsoleInterface/Menu.cpp +++ b/src/ConsoleInterface/Menu.cpp @@ -17,7 +17,7 @@ void Menu::navigate() const { return; } - resetOrderedList(); + resetOrderedList(0); printOrderedListElem("Go Back"); for (unsigned i = 0; i < menuOptions.get_count(); i++) printOrderedListElem(menuOptions[i].get_nameInMenu()); @@ -28,9 +28,8 @@ void Menu::navigate() const { print(menuOptions.get_count()); print("]: "); read(buffer); - } - - if (buffer == 0) return; - menuOptions[buffer - 1].run(); + if (buffer == 0) return; + menuOptions[buffer].run(); + } } diff --git a/src/List/List.hpp b/src/List/List.hpp index 1e75c89..7088f2e 100644 --- a/src/List/List.hpp +++ b/src/List/List.hpp @@ -70,9 +70,11 @@ void List::copyFrom(const List& other) { template List::List(const T* elements, unsigned elementsCount) { - count = length = 0; - for (unsigned i = 0; i < elementsCount; i++) - add(elements[i]); + length = 8; + count = elementsCount; + this->elements = new T[length]; + for (unsigned i = 0; i < count; i++) + this->elements[i] = elements[i]; } template -- cgit v1.3.1-23-gd82d