Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Polymorphism.NoPoly
- {
- public class Bank
- {
- private List<Person> Clients { get; set; }
- private List<PravnoLice> Klijenti { get; set; }
- private List<DrawingAccount> Accounts { get; set; }
- private List<DravingAkaunt> Akaunt { get; set; }
- public Bank()
- {
- Clients = new List<Person>();
- Accounts = new List<DrawingAccount>();
- }
- public void addClient(Person p)
- {
- Clients.Add(p);
- }
- public void dodajKlijenta(PravnoLice p)
- {
- Klijenti.Add(p);
- }
- public void openAccountForPerson(Person p)
- {
- DrawingAccount acc = new DrawingAccount(0) {
- AccountIdentity= Accounts.Count
- };
- Accounts.Add(acc);
- p.Accounts.Add(acc);
- }
- public void openAkauntForPravno( PravnoLice p)
- {
- DravingAkaunt acc = new DravingAkaunt(0)
- {
- AkauntIdentiti = Akaunt.Count
- };
- Akaunt.Add(acc);
- p.Akaunt.Add(acc);
- }
- public Person findClient(Int32 identity)
- {
- return Clients.Single(person => person.Identity == identity);
- }
- public void depositMoney(DrawingAccount acc, Decimal amount)
- {
- acc.deposit(amount);
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Polymorphism.NoPoly
- {
- public class PravnoLice
- {
- public List<DravingAkaunt> Akaunt
- {
- get;
- set;
- }
- public string Ime
- {
- get;
- set;
- }
- public string Adresa
- {
- get;
- set;
- }
- public PravnoLice()
- {
- Akaunt = new List<DravingAkaunt>();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Polymorphism.NoPoly
- {
- public class DravingAkaunt
- {
- private static Decimal limit = 1000;
- public Int32 AkauntIdentiti { get; set; }
- private Decimal _balans;
- public DravingAkaunt(Decimal startingBalance)
- {
- _balans = startingBalance;
- }
- public Decimal Statuss
- {
- get
- {
- return _balans;
- }
- }
- public void depozit(Decimal amount)
- {
- if (amount < 0)
- {
- throw new Exception("Amount's got to be positive in order to deposit money.");
- }
- _balans += amount;
- }
- public void withtekuci(Decimal amount)
- {
- if (amount < 0)
- {
- throw new Exception("Amount's got to be positive in order to withdraw money.");
- }
- else if (amount > limit)
- {
- throw new Exception("Amount's got to be smaller than security limit for single transaction.");
- }
- _balans -= amount;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement