示例#1
0
        private void button2_Click(object sender, EventArgs e)
        {
            Creature creature = new Villager();
            ///透過介面可以定義我們特別要求存在的method,但不需要用原本Creature變數就可以使用這個method
            IAttackable someone = new Monster();

            someone.attack(creature);

            MessageBox.Show(creature.say());
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Creature creature = new Villager();

            MessageBox.Show(creature.say());
        }