File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
Creational/Method Chaining/Golang Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "fmt"
5
+ )
6
+
7
+ type Player_Stat struct {
8
+ GamesPlayed float64
9
+ GoalScored float64
10
+ ShotOnTarget float64
11
+ Assist float64
12
+ }
13
+
14
+ func (s * Player_Stat ) GoalsRatio (goals , gamesplayed float64 ) * Player_Stat {
15
+ s .GoalScored = goals
16
+ s .GamesPlayed = gamesplayed
17
+
18
+ Goalsratio := s .GoalScored / s .GamesPlayed
19
+ fmt .Printf ("\n Player goal ratio is : %f" , Goalsratio )
20
+ return s
21
+
22
+ }
23
+
24
+ func (s * Player_Stat ) SOT_Ratio (Sot float64 ) * Player_Stat {
25
+ s .ShotOnTarget = Sot
26
+ sotRatio := float64 (s .ShotOnTarget / s .GamesPlayed )
27
+ println (s .ShotOnTarget )
28
+
29
+ fmt .Printf ("\n The player shot on target ratio is : %f" , sotRatio )
30
+
31
+ return s
32
+ }
33
+
34
+ func (s * Player_Stat ) AssistRatio (assist float64 ) {
35
+
36
+ s .Assist = assist
37
+
38
+ AssistRatio := s .Assist / s .GamesPlayed
39
+
40
+ fmt .Printf ("\n The assist ratio is : %f" , AssistRatio )
41
+ }
42
+
43
+ func main () {
44
+ ps := Player_Stat {}
45
+ ps .GoalsRatio (20 , 40 ).SOT_Ratio (55 ).AssistRatio (15 )
46
+ }
You can’t perform that action at this time.
0 commit comments