Documentation
¶
Overview ¶
Example (One) ¶
package main
import "fmt"
func main() {
wallet := NewWallet("Wechat Pay", 100)
wallet.Chain(
NewWallet("Alipay", 80)).Chain(
NewWallet("Bank Card", 200))
outputFailedPayment(wallet.Pay(50), 50)
outputFailedPayment(wallet.Pay(100), 100)
outputFailedPayment(wallet.Pay(60), 60)
outputFailedPayment(wallet.Pay(150), 150)
}
func outputFailedPayment(ok bool, amount int) {
if !ok {
fmt.Printf("error: wallet balance less then %d$\n", amount)
}
}
Output: Wechat Pay: succeed to deduct 50$ Bank Card: succeed to deduct 100$ Alipay: succeed to deduct 60$ error: wallet balance less then 150$
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BankCardPay ¶
type BankCardPay struct {
// contains filtered or unexported fields
}
func (*BankCardPay) Pay ¶
func (p *BankCardPay) Pay(amount int) bool
Click to show internal directories.
Click to hide internal directories.