Exemplo n.º 1
0
        static void Main(string[] args)
        {
            MoneyBag bag    = new MoneyBag();
            Money    moneyA = new Money(10, "EUR");
            Money    moneyB = new Money(20, "USD");
            Money    moneyC = new Money(15, "EUR");
            Money    moneyD = new Money(25, "JPY");
            IMoney   money  = bag.AddMoney(moneyA);

            money = money.AddMoney(moneyB);
            money = money.AddMoney(moneyC);
            money = money.AddMoney(moneyD);
            Console.WriteLine("My Portfolio : " + money.ToString());
            Console.ReadLine();
        }
Exemplo n.º 2
0
 //Hier wird alles sehr bequem gehandelt - und alles ist Typensicher
 static void Interface(object parameter)
 {
     //Zunächst mal überprüfen
     if (parameter is IMoney)
     {
         //as wirft keine Exception wenn der Cast nicht klappt - hier eigentlich unnötig
         IMoney typ = parameter as IMoney;
         typ.AddMoney(1.0m, "Interface");
     }
 }
Exemplo n.º 3
0
 /// <summary>Adds a money to this money. Forwards the request to
 /// the AddMoney helper.</summary>
 public IMoney Add(IMoney m)
 {
     return(m.AddMoney(this));
 }
Exemplo n.º 4
0
 /// <summary>Adds a money to this money. Forwards the request to
 /// the AddMoney helper.</summary>
 public IMoney Add(IMoney m)
 {
     return m.AddMoney(this);
 }