1 Star 0 Fork 0

CaptialSTeam/ubdframe

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
sts.go 839 Bytes
一键复制 编辑 原始数据 按行查看 历史
sage 提交于 2024-12-26 13:52 +08:00 . modify
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"
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/captials-team/ubdframe.git
git@gitee.com:captials-team/ubdframe.git
captials-team
ubdframe
ubdframe
v1.0.2

搜索帮助