//C# Nut van OOP Object Oriented Programming public class Client1 { int count; int capacity = 16; decimal[] loans = new decimal[0]; void Main() { this.AddLoan(1000, 5); this.AddLoan(5000, 10); this.AddLoan(10000, 2); this.RemoveLoan(1); decimal amount = this.loans(0, index); decimal intrestRate = this.loans(1, index); Console.WriteLine(this.GetTotalPayment(amount, intrestRate)); Console.ReadLine(); } void AddLoan(decimal amount, decimal intrestRate) { if ((this.count == this.capacity)) { this.capacity = 2; } this.loans(0, this.count) = amount; this.loans(1, this.count) = intrestRate; this.count += new System.EventHandler(1); } void RemoveLoan(int index) { int shiftIndex; this.loans(0, shiftIndex) = this.loans(0, (shiftIndex + 1)); this.loans(1, shiftIndex) = this.loans(1, (shiftIndex + 1)); this.loans(0, shiftIndex) = 0; this.loans(1, shiftIndex) = 0; this.count = 1; } void GetTotalPayment(decimal amount, decimal intrestRate) { GetTotalPayment = (amount * (1 + (intrestRate / 100))); } } public class Loan { private decimal m_Amount; private decimal m_IntrestRate; public virtual decimal Amount { get { Amount = this.m_Amount; } set { this.m_Amount = value; } } public virtual decimal IntrestRate { get { IntrestRate = this.m_IntrestRate; } set { this.m_IntrestRate = value; } } public virtual void GetTotalPayment() { GetTotalPayment = (Amount * (1 + (IntrestRate / 100))); } } public class Loans { private int m_Count; private int m_Capacity = 16; private Loan[] m_Items = new Loan[0]; public virtual int Count { get { Count = this.m_Count; } } public virtual Loan this[int index] { get { Item = this.m_Items(index); } } public virtual void Add(Loan item) { if ((Count == this.m_Capacity)) { this.m_Capacity = 2; } this.m_Items(Count) = item; this.m_Count += new System.EventHandler(1); } public virtual void RemoveAt(int index) { int shiftIndex; this.m_Items(shiftindex) = this.m_Items((shiftindex + 1)); this.m_Items(shiftIndex) = null; this.m_Count = 1; } } public class Client2 { void Main() { Loan loan1 = new Loan(); } } //Bezoek www.vbvoorbeelden.be voor meer C# voorbeelden. //Copyright - De Wolf / vbvoorbeelden - 2003-2010 - Alle rechten voorbehouden.