diff --git a/wallet/wallet.go b/wallet/wallet.go new file mode 100644 index 0000000..440ff47 --- /dev/null +++ b/wallet/wallet.go @@ -0,0 +1,13 @@ +package wallet + +type Wallet struct { + balance int +} + +func (w *Wallet) Deposit(units int) { + w.balance += units +} + +func (w *Wallet) Balance() int { + return w.balance +} diff --git a/wallet/wallet_test.go b/wallet/wallet_test.go new file mode 100644 index 0000000..e17a7a9 --- /dev/null +++ b/wallet/wallet_test.go @@ -0,0 +1,16 @@ +package wallet + +import "testing" + +func TestWallet(t *testing.T) { + wallet := Wallet{} + + wallet.Deposit(10) + + got := wallet.Balance() + want := 10 + + if got != want { + t.Errorf("got %d want %d", got, want) + } +}