wallet: use self defined type Bitcoin
This commit is contained in:
parent
8644bf547b
commit
71bc024fe2
@ -1,13 +1,15 @@
|
||||
package wallet
|
||||
|
||||
type Bitcoin int
|
||||
|
||||
type Wallet struct {
|
||||
balance int
|
||||
balance Bitcoin
|
||||
}
|
||||
|
||||
func (w *Wallet) Deposit(units int) {
|
||||
w.balance += units
|
||||
func (w *Wallet) Deposit(amount Bitcoin) {
|
||||
w.balance += amount
|
||||
}
|
||||
|
||||
func (w *Wallet) Balance() int {
|
||||
func (w *Wallet) Balance() Bitcoin {
|
||||
return w.balance
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ func TestWallet(t *testing.T) {
|
||||
wallet.Deposit(10)
|
||||
|
||||
got := wallet.Balance()
|
||||
want := 10
|
||||
want := Bitcoin(10)
|
||||
|
||||
if got != want {
|
||||
t.Errorf("got %d want %d", got, want)
|
||||
|
Loading…
Reference in New Issue
Block a user