Files
01-get-started
02-write-your-first-program
03-packages-and-scopes
04-statements-expressions-comments
05-write-your-first-library-package
06-variables
07-printf
08-numbers-and-strings
09-go-type-system
10-constants
11-if
12-switch
13-loops
14-arrays
15-project-retro-led-clock
16-slices
17-project-empty-file-finder
18-project-bouncing-ball
19-strings-runes-bytes
20-project-spam-masker
21-project-text-wrapper
22-maps
23-input-scanning
24-structs
25-functions
26-pointers
advfuncs
assets
concurrency
etc
first
interfaces
01-methods
02-receivers
03-nonstructs
book.go
game.go
list.go
main.go
money.go
04-interfaces
05-type-assertion
06-empty-interface
07-type-switch
08-promoted-methods
09-little-refactor
10-stringer
11-sort
12-marshaler
13-io
14-io-reusable
15-png-detector
16-io-compose
17-write-an-io-reader
18-testing
logparser
magic
magicpanic
translation
x-tba
.gitignore
LICENSE
README.md
go.mod
go.sum
main.go

25 lines
539 B
Go
Raw Permalink Normal View History

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