-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
76 lines (69 loc) · 1.55 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include"smoothie.h"
using namespace std;
int main()
{
Zutat z1{"Apfel"};
try
{
Zutat z1{""};
cout << "Error 1\n";
}
catch (runtime_error& e)
{
cout << "Leerer Name nicht erlaubt!\n";
}
try
{
Zutat z2("Abfel", 200);
cout << "Error 2\n";
}
catch (runtime_error& e)
{
cout << "Brennwert zu hoch!\n";
}
try
{
Zutat z2("Apfel", 0);
cout << "Error 3\n";
}
catch (runtime_error& e)
{
cout << "Brennwert zu niedrig!\n";
}
cout << (z1==Zutat{"Apfel", 12}) << (Zutat{"Birne"}==z1) << (z1==Zutat{"Apfel", 32}) << '\n';
cout << z1.brennwert() << Zutat{"Birne", 17} .brennwert() << '\n';
cout << Zutat{"Birne", 17} << z1 << '\n';
try
{
Smoothie s{""};
cout << "Error 3\n";
}
catch (runtime_error& e)
{
cout << "Smoothie muss eine Bezeichung haben!\n";
}
Smoothie s{"Turm von Hanoi"};
s.hinzu(Zutat{"Apfel"});
s.hinzu(Zutat{"Birne",31});
s.hinzu(Zutat{"Apfel",32});
cout << s << ", " << s.brennwert() << '\n';
cerr << s << '\n';
//Dekommentieren fuer Zusatzbeispiel unterheben
s.unterheben(Zutat{"Banane", 40});
cout << s << '\n';
try
{
Smoothie{"Test"} .unterheben(z1);
cout << "Error 4\n";
}
catch (runtime_error& e)
{
cout << "Unterheben nicht moeglich!\n";
}
//Dekommentieren fuer Zusatzbeispiel liste
s.liste(cout);
cout << '\n';
s.liste(cerr);
cerr << '\n';
return 0;
}