From c2e6b6f97ca7d688182b04cca7420a894ed1c879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20B=C3=B6rchers?= Date: Fri, 2 Nov 2018 20:40:32 +0100 Subject: [PATCH] Done! --- Eisverkauf/Eisverkauf.cpp | 84 ++++++++++++++++++++++++++++------- Eisverkauf/Eisverkauf.vcxproj | 2 +- 2 files changed, 68 insertions(+), 18 deletions(-) diff --git a/Eisverkauf/Eisverkauf.cpp b/Eisverkauf/Eisverkauf.cpp index 1178758..0f73573 100644 --- a/Eisverkauf/Eisverkauf.cpp +++ b/Eisverkauf/Eisverkauf.cpp @@ -1,35 +1,85 @@ -// Eisverkauf.cpp : Diese Datei enthält die Funktion "main". Hier beginnt und endet die Ausführung des Programms. -// - -#include "pch.h" #include +#include using namespace std; -void Greeting(); - -double GetPrice(int index); +void greeting(); +double order(vector persons, double available_money); +void billing(double change, double available_money); +double get_price(int index); +/** + * \brief ice cream sale + * \return zero if successful. + */ int main() { - double - Greeting(); - + const auto persons = {"Freund 1", "Freund 2", "Du"}; + const auto available_money = 5.0; + + greeting(); + const auto change = order(persons, available_money); + billing(change, available_money); + return 0; } -void Greeting() +/** + * \brief Writes a greeting message. + */ +void greeting() { cout << "Hallo!" << endl; cout << "Folgende Eissorten sind vorhanden:" << endl; - cout << "1. Capri: 1,10 €" << endl; - cout << "2. Nogger: 1,60 €" << endl; - cout << "3. Cornetto : 2,30 €" << endl; - - + cout << "1. Capri: 1,10 Euro" << endl; + cout << "2. Nogger: 1,60 Euro" << endl; + cout << "3. Cornetto : 2,30 Euro" << endl; + cout << endl; } +/** + * \brief Take an order and pay attention to the available money. + * \param persons The people at the counter + * \param available_money Available money + * \return Remaining money. + */ +double order(vector persons, double available_money) +{ + for (auto person : persons) + { + cout << "Hallo " << person << "!" << endl; + if (available_money < 1.1) + { + cout << "Sie koennen kein Eis mehr kaufen." << endl; + break; + } + cout << "Bitte geben Sie ihre Bestellung auf (1-3): "; + int input; + cin >> input; + available_money -= get_price(input); + } + return available_money; +} -double GetPrice(int index) +/** + * \brief Creates the bill and returns the change + * \param change The remaining money + * \param available_money The payed money. + */ +void billing(const double change, const double available_money) +{ + cout << endl; + cout << "Zu zahlender Betrag: " << available_money - change << " Euro" << endl; + cout << "Ihr Restgeld betraegt: " << change << " Euro" << endl; + cout << endl; + cout << "Danke, beehren sie uns bald wieder!"; +} + +/** + * \brief get prices of chosen product. + * \param index of the product. + * \return the price of the product. + */ +double get_price(const int index) { switch (index) { diff --git a/Eisverkauf/Eisverkauf.vcxproj b/Eisverkauf/Eisverkauf.vcxproj index 143e175..8961fed 100644 --- a/Eisverkauf/Eisverkauf.vcxproj +++ b/Eisverkauf/Eisverkauf.vcxproj @@ -84,7 +84,7 @@ - Use + NotUsing Level3 Disabled true