test: 修改 Demo29 适配最新语法
This commit is contained in:
parent
a57d666241
commit
5ec4f9ec6a
@ -13,6 +13,13 @@ module: Main
|
|||||||
this.city = city
|
this.city = city
|
||||||
end body
|
end body
|
||||||
end init
|
end init
|
||||||
|
|
||||||
|
function: getCity
|
||||||
|
returns: int
|
||||||
|
body:
|
||||||
|
return this.city
|
||||||
|
end body
|
||||||
|
end function
|
||||||
end struct
|
end struct
|
||||||
|
|
||||||
struct: Person
|
struct: Person
|
||||||
@ -35,6 +42,13 @@ module: Main
|
|||||||
return this.name
|
return this.name
|
||||||
end body
|
end body
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function: getAddr
|
||||||
|
returns: Address
|
||||||
|
body:
|
||||||
|
return this.addr
|
||||||
|
end body
|
||||||
|
end function
|
||||||
end struct
|
end struct
|
||||||
|
|
||||||
function: main
|
function: main
|
||||||
@ -42,8 +56,9 @@ module: Main
|
|||||||
body:
|
body:
|
||||||
// 初始化 Person 和 Address 的实例
|
// 初始化 Person 和 Address 的实例
|
||||||
declare p: Person = new Person(123, new Address(1, 2))
|
declare p: Person = new Person(123, new Address(1, 2))
|
||||||
|
os.println(p.getName()) // 打印 name
|
||||||
|
os.println(p.getAddr().getCity()) // 打印 city
|
||||||
|
|
||||||
os.print(p.getName()) // 打印 name
|
|
||||||
end body
|
end body
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user