Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

cleaning up

  • Loading branch information...
commit 864504be4cb07ed791037cad83d2a09cd3dff71a 1 parent 62b6352
authored April 09, 2011

Showing 1 changed file with 7 additions and 8 deletions. Show diff stats Hide diff stats

  1. 15  greenland_bank.js
15  greenland_bank.js
... ...
@@ -1,6 +1,5 @@
1  
-
2 1
 var moneySource = {
3  
-	transferTo: function(amount, recipient){
  2
+	transferTo: function(amount, recipient) {
4 3
 		this.decreaseBalance(amount);
5 4
 		recipient.transferFrom(amount);
6 5
 	},
@@ -10,8 +9,7 @@ var moneySource = {
10 9
 };
11 10
 
12 11
 var moneySink = {
13  
-	updateLog: function(message, time, amount){},
14  
-	transferFrom: function(amount){
  12
+	transferFrom: function(amount) {
15 13
 		this.increaseBalance(amount);
16 14
 		this.updateLog('Transfer in', '2001-01-01', amount);
17 15
 	}
@@ -27,7 +25,7 @@ var transferMoneyContext = {
27 25
 
28 26
 var savingsAccount = {
29 27
 	balance: 1000,
30  
-	accountId: null,
  28
+	accountId: 'savings',
31 29
 
32 30
 	decreaseBalance: function(amount) {
33 31
 		this.balance = this.balance - amount;
@@ -36,11 +34,11 @@ var savingsAccount = {
36 34
 		this.balance = this.balance + amount;
37 35
 	},
38 36
 	updateLog: function(msg, date, amount) {
39  
-		console.log("Account: " + accountId + ", message: " + msg + ", date: " + date + ", amount: " + amount);
  37
+		console.log("Account: " + this.accountId + ", message: " + msg + ", date: " + date + ", amount: " + amount);
40 38
 	},
41 39
 	addRole: function(role) {
42  
-		for(name in role){
43  
-			if(role.hasOwnProperty(name) && typeof role[name] === 'function'){
  40
+		for(name in role) {
  41
+			if(role.hasOwnProperty(name) && typeof role[name] === 'function') {
44 42
 				this[name] = role[name];
45 43
 			}
46 44
 		}
@@ -49,6 +47,7 @@ var savingsAccount = {
49 47
 
50 48
 var checkingAccount = Object.create(savingsAccount);
51 49
 checkingAccount.balance = 0;
  50
+checkingAccount.accountId = 'checking';
52 51
 
53 52
 transferMoneyContext.execute(300, savingsAccount, checkingAccount);
54 53
 transferMoneyContext.execute(100, checkingAccount, savingsAccount);

0 notes on commit 864504b

Please sign in to comment.
Something went wrong with that request. Please try again.