代码拉取完成,页面将自动刷新
package resource
import "fmt"
type IPeople interface {
Say()
GetMoney() int
GetName() string
GetTypeText() string
SetName(string) bool
}
type People struct {
Name string
Money int
Age uint
}
func (People) GetTypeText() string {
return "People"
}
func (p People) GetName() string {
return p.Name
}
func (p People) SetName(name string) bool {
p.Name = name
return true
}
func (p People) GetMoney() int {
return p.Money
}
// Male 男性(继承上面的People)
type Male struct {
People
JJ int
}
func (Male) Say() {
fmt.Println("Ah...o")
}
func (Male) GetTypeText() string {
return "strong men"
}
func (m *Male) Work() bool {
m.Money += 100
return true
}
type Female struct {
People
BB int
}
func (Female) Say() {
fmt.Println("Hi...i")
}
func (Female) GetTypeText() string {
return "beautifully women"
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。