Documentation
¶
Index ¶
- Constants
- func AddBonus(card *types.Card, percent int, daysInMonth int, daysInYear int)
- func Deposit(card *types.Card, amount types.Money)
- func IssueCard(currency types.Currency, color string, name string) types.Card
- func PaymentSources(cards []types.Card) []types.PaymentSource
- func Total(cards []types.Card) types.Money
- func Withdraw(card *types.Card, amount types.Money)
Examples ¶
Constants ¶
View Source
const PercentBonus int = 3
Variables ¶
This section is empty.
Functions ¶
func AddBonus ¶
Example (Inactive) ¶
card := types.Card{Balance: 20_000_00, Active: false}
AddBonus(&card, PercentBonus, 30, 365)
fmt.Println(card.Balance)
Output: 2000000
Example (Limit) ¶
card := types.Card{Balance: 3_000_000_00, Active: true}
AddBonus(&card, PercentBonus, 30, 365)
fmt.Println(card.Balance)
Output: 300500000
Example (NoMoney) ¶
card := types.Card{Balance: -10, Active: true}
AddBonus(&card, PercentBonus, 30, 365)
fmt.Println(card.Balance)
Output: -10
Example (Positive) ¶
card := types.Card{Balance: 10_000_00, Active: true}
AddBonus(&card, PercentBonus, 30, 365)
fmt.Println(card.Balance)
Output: 1002465
func Deposit ¶
Example (Inactive) ¶
card := types.Card{Balance: 20_000_00, Active: false}
Deposit(&card, 10_000_00)
fmt.Println(card.Balance)
Output: 2000000
Example (Limit) ¶
card := types.Card{Balance: 200_000_00, Active: true}
Deposit(&card, 60_000_00)
fmt.Println(card.Balance)
Output: 20000000
Example (Positive) ¶
card := types.Card{Balance: 20_000_00, Active: true}
Deposit(&card, 10_000_00)
fmt.Println(card.Balance)
Output: 3000000
func PaymentSources ¶
func PaymentSources(cards []types.Card) []types.PaymentSource
Example ¶
cards := []types.Card{
{
Balance: 10_000_00,
Active: true,
PAN: "12121 21212 1212",
},
{
Balance: 50_000_00,
Active: true,
PAN: "12121 12 1212",
},
{
Balance: -10_000_00,
Active: false,
PAN: "12121 21212 1212",
},
}
paymentSources := PaymentSources(cards)
fmt.Println(len(paymentSources))
Output: 2
func Total ¶
Example ¶
cards := []types.Card{
{
Balance: 10_000_00,
Active: true,
},
{
Balance: 10_000_00,
Active: false,
},
{
Balance: -10_000_00,
Active: false,
},
}
fmt.Println(Total(cards))
Output: 1000000
func Withdraw ¶
Example (Inactive) ¶
card := types.Card{Balance: 20_000_00, Active: false}
Withdraw(&card, 10_000_00)
fmt.Println(card.Balance)
Output: 2000000
Example (Limit) ¶
card := types.Card{Balance: 200_000_00, Active: true}
Withdraw(&card, 30_000_00)
fmt.Println(card.Balance)
Output: 20000000
Example (NoMoney) ¶
card := types.Card{Balance: 0, Active: true}
Withdraw(&card, 10_000_00)
fmt.Println(card.Balance)
Output: 0
Example (Positive) ¶
card := types.Card{Balance: 20_000_00, Active: true}
Withdraw(&card, 10_000_00)
fmt.Println(card.Balance)
Output: 1000000
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.