author | Markus Bröker<broeker.markus@googlemail.com> |
Wed, 29 Mar 2017 12:48:46 +0200 | |
changeset 2 | 0907765a8b2e |
parent 1 | 80c685d55d63 |
permissions | -rwxr-xr-x |
0 | 1 |
/** |
2 |
* Invoice.cs |
|
3 |
* |
|
2
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
4 |
* The MIT License (MIT) |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
5 |
* |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
6 |
* @copyright Copyright(C) 2017 4Customers UG |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
7 |
* @author Markus Bröker<broeker.markus@googlemail.com> |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
8 |
* |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
9 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
10 |
* of this software and associated documentation files (the "Software"), to deal |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
11 |
* in the Software without restriction, including without limitation the rights |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
12 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
13 |
* copies of the Software, and to permit persons to whom the Software is |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
14 |
* furnished to do so, subject to the following conditions: |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
15 |
* |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
16 |
* The above copyright notice and this permission notice shall be included in all |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
17 |
* copies or substantial portions of the Software. |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
18 |
* |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
19 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
20 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
21 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
22 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
23 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
24 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
0907765a8b2e
Visual Studio / Xamarin Studio Lizenzbedingungen beachten
Markus Bröker<broeker.markus@googlemail.com>
parents:
1
diff
changeset
|
25 |
* SOFTWARE. |
0 | 26 |
*/ |
27 |
using System; |
|
28 |
using System.Collections.Generic; |
|
29 |
using System.Linq; |
|
30 |
using System.Text; |
|
31 |
using System.Threading.Tasks; |
|
32 |
||
33 |
using static Sales.Payment; |
|
34 |
||
35 |
namespace Sales |
|
36 |
{ |
|
37 |
delegate double InvoiceDelegate(); |
|
38 |
||
39 |
class Invoice |
|
40 |
{ |
|
41 |
private double value = 0; |
|
42 |
private PaymentType till; |
|
43 |
||
44 |
public Invoice(double value, PaymentType till) |
|
45 |
{ |
|
46 |
this.value = value; |
|
47 |
this.till = till; |
|
48 |
||
49 |
InvoiceDelegate invoiceDelegateReference = this.Rabatt; |
|
50 |
invoiceDelegateReference += this.AddTax; |
|
51 |
invoiceDelegateReference += this.Skonto; |
|
52 |
||
53 |
invoiceDelegateReference(); |
|
54 |
} |
|
55 |
||
56 |
public double getFinalResult() |
|
57 |
{ |
|
58 |
return value; |
|
59 |
} |
|
60 |
||
1
80c685d55d63
Sinnvolles Beispiel für Function-Pointer in C#
Markus Bröker<broeker.markus@googlemail.com>
parents:
0
diff
changeset
|
61 |
// Rabatt auf den Netto Preis |
0 | 62 |
private double Rabatt() |
63 |
{ |
|
64 |
if (value > 1000.0) |
|
65 |
{ |
|
66 |
value *= 0.75; |
|
67 |
} |
|
68 |
else if (value > 500.0) |
|
69 |
{ |
|
70 |
value *= 0.85; |
|
71 |
} |
|
72 |
||
73 |
return value; |
|
74 |
} |
|
75 |
||
76 |
// Steuern auf den rabattierten Nettopreis |
|
77 |
private double AddTax() |
|
78 |
{ |
|
79 |
value *= 1.19; |
|
80 |
return value; |
|
81 |
} |
|
82 |
||
83 |
// Skonto immer zum Schluss |
|
84 |
private double Skonto() |
|
85 |
{ |
|
86 |
switch (till) |
|
87 |
{ |
|
88 |
case PaymentType.NOW: |
|
89 |
value *= 0.97; |
|
90 |
break; |
|
91 |
case PaymentType.WEEK: |
|
92 |
value *= 0.98; |
|
93 |
break; |
|
94 |
case PaymentType.MONTH: |
|
95 |
value *= 0.99; |
|
96 |
break; |
|
97 |
} |
|
98 |
||
99 |
return value; |
|
100 |
} |
|
101 |
} |
|
102 |
} |