2019-08-20 19:03:57 +03:00
|
|
|
// 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"
|
|
|
|
|
|
|
|
type puzzle struct {
|
|
|
|
title string
|
2019-08-21 23:53:47 +03:00
|
|
|
price money
|
2019-08-20 19:03:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *puzzle) print() {
|
2019-08-21 23:53:47 +03:00
|
|
|
fmt.Printf("%-15s: %s\n", p.title, p.price.string())
|
2019-08-20 19:03:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *puzzle) discount(ratio float64) {
|
2019-08-21 23:53:47 +03:00
|
|
|
p.price *= money(1 - ratio)
|
2019-08-20 19:03:57 +03:00
|
|
|
}
|