Files
hakorune/tests/development/test_normal_delegation.hako

57 lines
1.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 🔄 通常のデリゲーションpack使用しない
// 親Box
box Animal {
init { name, species }
init(animalName, animalSpecies) {
me.name = animalName
me.species = animalSpecies
print("🐾 Animal init: " + animalName + " (" + animalSpecies + ")")
}
speak() {
return me.name + " makes a sound"
}
}
// 子Box - 通常のデリゲーションpack使わない
box Dog from Animal {
init { breed }
init(dogName, dogBreed) {
from Animal.init(dogName, "Dog")
me.breed = dogBreed
print("🐕 Dog init: " + dogName + " (breed: " + dogBreed + ")")
}
override speak() {
return me.name + " barks!"
}
getBreed() {
return me.breed
}
}
static box Main {
init { console }
main() {
me.console = new ConsoleBox()
me.console.log("🔄 通常のデリゲーションテストpack使用なし")
// 通常のデリゲーションでDogインスタンス作成
local myDog = new Dog("Rex", "German Shepherd")
me.console.log("✅ Dog作成成功")
// メソッド呼び出し
local sound = myDog.speak()
me.console.log("🔊 " + sound)
local breed = myDog.getBreed()
me.console.log("🐕 犬種: " + breed)
return "通常デリゲーションテスト成功"
}
}