Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using System.Linq;
- namespace BankAccount
- {
- public class StartUp
- {
- private static void Main(string[] args)
- {
- //Person person = new Person();
- //person.Name = "Pesho";
- //person.Age = 23;
- //Person person2 = new Person();
- //person2.Name = "Stamat";
- //person2.Age = 33;
- //Person person3 = new Person();
- //person3.Name = "Gosho";
- //person3.Age = 11;
- //BankAccount bankAccount = new BankAccount();
- //person.GetBalance();
- }
- }
- public class BankAccount
- {
- private int id;
- private decimal balance;
- public int ID
- {
- get { return id; }
- set { id = value; }
- }
- public decimal Balance
- {
- get { return balance; }
- set { balance = value; }
- }
- }
- public class Person
- {
- private string name;
- private int age;
- private List<BankAccount> accounts;
- public Person(string name, int age)
- {
- this.name = name;
- this.age = age;
- accounts = new List<BankAccount>();
- }
- public Person(string name, int age, List<BankAccount> accounts)
- {
- this.name = name;
- this.age = age;
- this.accounts = accounts;
- }
- public List<BankAccount> Accounts
- {
- get { return accounts; }
- set { accounts = value; }
- }
- public int Age
- {
- get { return age; }
- set { age = value; }
- }
- public string Name
- {
- get { return name; }
- set { name = value; }
- }
- public decimal GetBalance()
- {
- return accounts.Sum(x => x.Balance);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement