From 0094764a3483bb31958b547b7658123073bb5231 Mon Sep 17 00:00:00 2001 From: Holger Boerchers Date: Wed, 26 Dec 2018 13:54:40 +0100 Subject: [PATCH] working on.. --- src/Motorradvermietung.cpp | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/Motorradvermietung.cpp b/src/Motorradvermietung.cpp index c42f798..2c230c6 100644 --- a/src/Motorradvermietung.cpp +++ b/src/Motorradvermietung.cpp @@ -156,26 +156,24 @@ private: customer* customer_; public: reservation(string start, string end, const short motorcycle, customer* customer) : id_(++next_reservation_id), - start_( - std::move(start)), end_( - std::move(end)), + start_(move(start)), + end_(move(end)), motorcycle_(motorcycle), customer_(customer) { } }; -string motorcycles[] = { +string motorcycles[] = +{ "Suzuki Bandit", "Honda TransAlp", - "BMW F 650 GS" + "BMW F 650 GS", "Kawasaki ZZR1400" }; list customers; list reservations; -int size_of_motorcycles = 4; - void create_customer(); void create_reservation(); void rent_a_motorcycle(); @@ -302,6 +300,26 @@ customer* find_customer_by_first_name(const vector& filtered_customer return nullptr; } +int select_motorcycle() +{ + while (true) + { + cout << "Bitte w\x84hlen sie ein Motorrad aus:" << endl; + auto index = 0; + for (const auto& cycle : motorcycles) + { + cout << ++index << ": " << cycle << endl; + } + const auto answer = ask_question("Auswahl"); + const auto size = static_cast(sizeof(motorcycles) / sizeof(*motorcycles)); + if (answer > 0 && answer <= size) + { + return answer - 1; + } + cout << "Ung\x81ltige Eingabe" << endl << endl; + } +} + void create_reservation() { system("cls"); @@ -332,7 +350,9 @@ void create_reservation() const auto start_date = get_validated_date("Startdatum"); const auto end_date = get_validated_date("Enddatum"); - auto r = reservation(start_date, end_date, 2, current); + const auto motorcycle = select_motorcycle(); + const auto r = new reservation(start_date, end_date, motorcycle, current); + reservations.push_back(r); } void rent_a_motorcycle()