2019-10-17 14:49:20 +03:00

34 lines
562 B
Go

// For more tutorials: https://blog.learngoprogramming.com
//
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
package main
import (
"fmt"
"strings"
)
type list []*product
func (l list) String() string {
if len(l) == 0 {
return "Sorry. We're waiting for delivery 🚚.\n"
}
var str strings.Builder
for _, p := range l {
fmt.Fprintf(&str, "* %s\n", p)
}
return str.String()
}
func (l list) discount(ratio float64) {
for _, p := range l {
p.discount(ratio)
}
}