Io自学笔记01

//animal
animal := Object clone
animal name := "name"

//dog
dog := animal clone
dog name := "dog"
dog isSit := false
dog bark := method(writeln("woof"))
dog sit := method(
	if(isSit==true,writeln("sitting now");bark;return;)
	isSit=true
	writeln("sit ok")
	bark
)

//fido
fido := dog clone
fido name := "fido"
fido bark := method(
	writeln("ruf")
)

//test
writeln("dog bark>>")
dog bark
writeln("dog sit>>")
dog sit
writeln("dog sit>>")
dog sit

writeln("fido bark>>")
fido bark
writeln("fido sit>>")
fido sit
writeln("fido sit>>")
fido sit

Comments are closed.