go-by-test/wallet/wallet.go

22 lines
284 B
Go
Raw Normal View History

package wallet
2024-09-11 09:17:23 +00:00
import "fmt"
2024-09-11 09:15:24 +00:00
type Bitcoin int
2024-09-11 09:17:23 +00:00
func (b Bitcoin) String() string {
return fmt.Sprintf("%d BTC", b)
}
type Wallet struct {
2024-09-11 09:15:24 +00:00
balance Bitcoin
}
2024-09-11 09:15:24 +00:00
func (w *Wallet) Deposit(amount Bitcoin) {
w.balance += amount
}
2024-09-11 09:15:24 +00:00
func (w *Wallet) Balance() Bitcoin {
return w.balance
}