Files

36 lines
658 B
Go
Raw Permalink Normal View History

2019-08-31 20:28:08 +03:00
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
2019-10-30 19:34:44 +03:00
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus
2019-08-31 20:28:08 +03:00
package main
import "fmt"
2019-09-02 16:48:38 +03:00
type item interface {
2019-08-31 20:28:08 +03:00
print()
discount(ratio float64)
2019-08-31 20:28:08 +03:00
}
2019-09-02 16:48:38 +03:00
type list []item
2019-08-31 20:28:08 +03:00
func (l list) print() {
if len(l) == 0 {
fmt.Println("Sorry. We're waiting for delivery 🚚.")
return
}
for _, it := range l {
it.print()
}
}
func (l list) discount(ratio float64) {
for _, it := range l {
2019-09-02 16:48:38 +03:00
it.discount(ratio)
2019-08-31 20:28:08 +03:00
}
}