23 lines
360 B
Go
23 lines
360 B
Go
|
package pointererror
|
||
|
|
||
|
import "fmt"
|
||
|
|
||
|
type Bitcoin int
|
||
|
|
||
|
func (b Bitcoin) String() string {
|
||
|
return fmt.Sprintf("%d BTC", b)
|
||
|
}
|
||
|
|
||
|
type Wallet struct {
|
||
|
balance Bitcoin
|
||
|
}
|
||
|
|
||
|
func (w *Wallet) Deposit(amount Bitcoin) {
|
||
|
w.balance += amount * 2
|
||
|
}
|
||
|
|
||
|
func (w *Wallet) Balance() Bitcoin {
|
||
|
fmt.Printf("address of balance in Balance is %p \n", &w.balance)
|
||
|
return w.balance
|
||
|
}
|