Created
January 9, 2017 16:22
-
-
Save yaravind/b01f90b3453d94798dbc6ab801a229ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
aliceAcct := OpenSavingsAccount("12345", "Alice", time.Date(1999, time.January, 03, 0, 0, 0, 0, time.UTC)) | |
fmt.Println("Alice's account =", aliceAcct) | |
aliceAcct.Deposit(Money(100.0)) | |
fmt.Println("Alice's account (after deposit) =", aliceAcct) | |
if err := aliceAcct.Withdraw(Money(10)); err != nil { | |
fmt.Println(err) | |
} else { | |
fmt.Println("Alice's account (after withdrawl) =", aliceAcct) | |
} | |
const overDraft = false | |
bobAcct := OpenCheckingAccount("98765", "Bob", time.Date(1997, time.April, 03, 0, 0, 0, 0, time.UTC), overDraft) | |
fmt.Println("\nBob's account =", bobAcct) | |
bobAcct.Deposit(Money(100.0)) | |
fmt.Println("Bob's account (after deposit) =", bobAcct) | |
if err := bobAcct.Withdraw(Money(77)); err != nil { | |
fmt.Println(err) | |
} else { | |
fmt.Println("Bob's account (after withdrawl) =", bobAcct) | |
} | |
fmt.Println("\nTransfering 10.0 from Alice to Bob's acct") | |
if err := Transfer(aliceAcct, bobAcct, Money(76.0)); err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println("Alice's account =", aliceAcct) | |
fmt.Println("Bob's account =", bobAcct) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment