public void run() { var person = new Person(); person.assets.Add(new BankAccount { amount = 1000, interest = 0.2 }); person.assets.Add(new Loan { owed = 200 }); person.assets.Add(new Loan { owed = 20 }); var nwv = new NetworthVisitor(); var iv = new IncomeVisitor(); person.Accept(nwv); person.Accept(iv); Console.WriteLine(nwv.total); Console.WriteLine(iv.Amount); }
public void run() { var person = new Person(); person.assets.Add(new BankAccount { amount=1000,interest=0.2}); person.assets.Add(new Loan { owed=200}); person.assets.Add(new Loan{owed=20 }); var nwv=new NetworthVisitor(); var iv = new IncomeVisitor(); person.Accept(nwv); person.Accept(iv); Console.WriteLine(nwv.total); Console.WriteLine(iv.Amount); }