Пример #1
0
 // Adds to balance and creates a ledger of the transaction
 // by checking whether there's room in history[] and making more if needed
 // then changing balance, creating the ledger entry and increasing historyCount
 public void NewTransaction(double change, string note)
 {
     if(!(historyCount < historyCap))
     {
         AddHistory(historyCap);
     }
     balance += change;
     history[historyCount] = new Ledger(DateTime.Now, change, balance, note);
     historyCount++;
 }
Пример #2
0
 // Doubles capacity of history[] and size of historyCap
 // by creating a newHistory[] and copying the old entries into it
 public void AddHistory(int cap)
 {
     int newCap = cap * 2;
     Ledger[] newHistory = new Ledger[newCap];
     for(int i = 0; i < cap; i++)
     {
         newHistory[i] = history[i];
     }
     history = newHistory;
     historyCap = newCap;
 }
Пример #3
0
 public void SetHistory(int id, Ledger _ledger)
 {
     history[id] = _ledger;
 }