class Program
{
static void Main(string[] args)
{
Coffee smallcoffee = new Smallcoffee();
ADD addsugar = new Sugar();
smallcoffee.Run(addsugar);
Console.ReadKey();
}
}
public interface ADD {
void add();
}
public class Milk :ADD{
public void add() {
Console.WriteLine("再加点牛奶");
}
}
public class Sugar : ADD {
public void add() {
Console.WriteLine("再加点糖");
}
}
public class Lemon : ADD {
public void add() {
Console.WriteLine("再加点柠檬");
}
}
public abstract class Coffee {
public abstract void Run(ADD add);
}
public class Bigcoffee : Coffee
{
public override void Run(ADD add)
{
Console.WriteLine("点一个大杯咖啡");
add.add();
}
}
public class Middlecoffee : Coffee
{
public override void Run(ADD add)
{
Console.WriteLine("点一个中杯咖啡");
add.add();
}
}
public class Smallcoffee : Coffee
{
public override void Run(ADD add)
{
Console.WriteLine("点一个小杯咖啡");
add.add();
}
}