Files
wagslane 9be3074de6 first
2023-05-01 15:25:27 -06:00

62 lines
883 B
Go

package main
import (
"fmt"
)
type employee interface {
getName() string
getSalary() int
}
type contractor struct {
name string
hourlyPay int
hoursPerYear int
}
func (c contractor) getName() string {
return c.name
}
func (c contractor) getSalary() int {
return c.hourlyPay * c.hoursPerYear
}
// don't touch below this line
type fullTime struct {
name string
salary int
}
func (ft fullTime) getSalary() int {
return ft.salary
}
func (ft fullTime) getName() string {
return ft.name
}
func test(e employee) {
fmt.Println(e.getName(), e.getSalary())
fmt.Println("====================================")
}
func main() {
test(fullTime{
name: "Jack",
salary: 50000,
})
test(contractor{
name: "Bob",
hourlyPay: 100,
hoursPerYear: 73,
})
test(contractor{
name: "Jill",
hourlyPay: 872,
hoursPerYear: 982,
})
}