This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class AbstractWeapon | |
{ | |
public abstract void shoot(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Ice : AbstractWeapon | |
{ | |
public override void shoot() | |
{ | |
Console.WriteLine("冰天箭!"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Cut : AbstractWeapon | |
{ | |
public override void shoot() | |
{ | |
Console.WriteLine("削切剪刀!"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Guts : AbstractWeapon | |
{ | |
public override void shoot() | |
{ | |
Console.WriteLine("超級手臂!"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Rockman | |
{ | |
private AbstractWeapon weapon; | |
public void setWeapon(AbstractWeapon weapon) | |
{ | |
this.weapon = weapon; | |
} | |
public void killEnemy() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Rockman rockman = new Rockman(); | |
rockman.setWeapon(new Cut()); | |
rockman.killEnemy(); | |
Console.ReadKey(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BreakfastShop | |
{ | |
public void cook(Hamburger hamburger) | |
{ | |
hamburger.recipe(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Hamburger | |
{ | |
public void recipe() | |
{ | |
Console.WriteLine("漢堡需要麵包皮、生菜、豬肉片、番茄片、起士"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Program | |
{ | |
static void Main(string[] args) | |
{ | |
BreakfastShop shop = new BreakfastShop(); | |
Hamburger hamburger = new Hamburger(); | |
shop.cook(hamburger); | |
Console.Read(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MilkTea | |
{ | |
public void recipe() | |
{ | |
Console.WriteLine("奶茶需要紅茶、牛奶、水"); | |
} | |
} |
OlderNewer