Created
January 1, 2012 15:59
-
-
Save ralfw/1547657 to your computer and use it in GitHub Desktop.
Einfaches FlowDesign Beispiel - Summe und MwSt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Summation | |
{ | |
class MainClass | |
{ | |
public static void Main (string[] args) | |
{ | |
var frontend = new Frontend(); | |
var rechenwerk = new Rechenwerk(); | |
frontend.Nettobetrag += rechenwerk.Summieren; | |
rechenwerk.Bruttosumme += frontend.Ausgabe; | |
frontend.Run(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Summation | |
{ | |
class Frontend { | |
public void Run() { | |
while(true) { | |
Console.Write("Nettobetrag: "); | |
var eingabe = Console.ReadLine(); | |
if (eingabe == "") break; | |
var nettobetrag = float.Parse(eingabe); | |
Nettobetrag(nettobetrag); | |
} | |
} | |
public event Action<float> Nettobetrag; | |
public void Ausgabe(float bruttosumme) { | |
Console.WriteLine(" Bruttosumme: {0}", bruttosumme); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Summation | |
{ | |
class Rechenwerk { | |
public void Summieren(float nettobetrag) { | |
var nettosumme = Berechne_Nettosumme(nettobetrag); | |
var mwstSumme = Berechne_Mehrwertsteuer(nettosumme); | |
var bruttosumme = Berechne_Gesamtsumme(nettosumme, mwstSumme); | |
Bruttosumme(bruttosumme); | |
} | |
public event Action<float> Bruttosumme; | |
float _nettosumme; | |
float Berechne_Nettosumme(float nettobetrag) { | |
_nettosumme += nettobetrag; | |
return _nettosumme; | |
} | |
float MWST_SATZ = 0.19f; | |
float Berechne_Mehrwertsteuer(float netto) { | |
return netto * MWST_SATZ; | |
} | |
float Berechne_Gesamtsumme(float netto, float mwst) { | |
return netto + mwst; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Flow-Design Diagramm:
https://cacoo.com/diagrams/maS4kLQC1MCvwtnG
Xing-Diskussion:
https://www.xing.com/net/pri9f1af9x/ebcfd/quelltexte-musterlosungen-best-practices-636557/flowdesign-umsetzung-in-unterschiedlichen-programmiersprachen-39272287/