26 lines
352 B
Go
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
|
|
}
|