Files
go-by-test/wallet/wallet.go
2024-09-11 11:22:12 +02:00

26 lines
352 B
Go

package wallet
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
}
func (w *Wallet) Withdraw(amount Bitcoin) {
w.balance -= amount
}
func (w *Wallet) Balance() Bitcoin {
return w.balance
}