24 lines
421 B
Go
Raw Normal View History

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