1
0
This commit is contained in:
Holger Börchers 2018-11-02 20:40:32 +01:00
parent 457473368c
commit c2e6b6f97c
2 changed files with 68 additions and 18 deletions

View File

@ -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 <iostream> #include <iostream>
#include <vector>
using namespace std; using namespace std;
void Greeting(); void greeting();
double order(vector<const char*> persons, double available_money);
double GetPrice(int index); void billing(double change, double available_money);
double get_price(int index);
/**
* \brief ice cream sale
* \return zero if successful.
*/
int main() int main()
{ {
double const auto persons = {"Freund 1", "Freund 2", "Du"};
Greeting(); 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 << "Hallo!" << endl;
cout << "Folgende Eissorten sind vorhanden:" << endl; cout << "Folgende Eissorten sind vorhanden:" << endl;
cout << "1. Capri: 1,10 €" << endl; cout << "1. Capri: 1,10 Euro" << endl;
cout << "2. Nogger: 1,60 €" << endl; cout << "2. Nogger: 1,60 Euro" << endl;
cout << "3. Cornetto : 2,30 €" << 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<const char*> 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) switch (index)
{ {

View File

@ -84,7 +84,7 @@
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>