-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.go
84 lines (63 loc) · 1.38 KB
/
app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package main
import(
"fmt"
)
// function that takes an empty interface as an arg
func myFunction(x interface{}){
fmt.Println(x)
}
type Employee interface {
Introduction()
}
type Programmer struct {
Name string
Ic string
Age int
Salary float64
}
type Cleaner struct {
Name string
Ic string
Age int
Salary float64
}
type Manager struct {
Name string
Ic string
Age int
Salary float64
}
// Introduction() defintions
func (x Programmer) Introduction() {
fmt.Println("Name :", x.Name)
fmt.Println("Ic :", x.Ic)
fmt.Println("Age :", x.Age)
fmt.Println("Salary :", x.Salary)
}
func (x Cleaner) Introduction() {
fmt.Println("Name :", x.Name)
fmt.Println("Ic :", x.Ic)
fmt.Println("Age :", x.Age)
fmt.Println("Salary :", x.Salary)
}
func (x Manager) Introduction() {
fmt.Println("Name :", x.Name)
fmt.Println("Ic :", x.Ic)
fmt.Println("Age :", x.Age)
fmt.Println("Salary :", x.Salary)
}
func main() {
num := 21
name := "Muaz Bin Wazir"
salary := 10000.00
// workaround for unsused variable error in golang
_, _ = name, num
// Any type can be pass into a fucntion that accepts an empty interface
myFunction(salary)
manager := Manager{"Afrina", "000000-00-0000", 20, 20000,}
programmer := Programmer{"Muaz", "0000000-00-0000", 21, 10000,}
cleaner := Cleaner{"Arep", "000000-00-0000", 21, 200,}
manager.Introduction()
programmer.Introduction()
cleaner.Introduction()
}