zoukankan      html  css  js  c++  java
  • 模拟顾客点餐





    public class order//菜单类 2 { 3 public Client customer;//顾客 4 public int id;//餐桌号 5 public string mealList;//点的菜单 6 }
     1 public  class Client//顾客类
     2     {
     3        //点餐
     4        public void Order(waitress waitress, order or)
     5        {
     6            Console.WriteLine("顾客开始点菜:{0}!",or.mealList);
     7            waitress.GetOrder(or);
     8        }
     9        //用餐
    10        public void Eat()
    11        {
    12            Console.WriteLine("客人用餐!");
    13        }
    14     }
     1  public class waitress//服务员类
     2     {
     3       private order or;
     4       public void GetOrder(order or)
     5       {
     6           this.or = or;
     7       }
     8       //给厨师提交菜单
     9       public void SendOrder(Chef chef)
    10       {
    11           Console.WriteLine("服务员将菜{0}传给厨师",or.mealList);
    12           chef.GetOrder(or);
    13 
    14       }
    15       //传菜
    16       public void TransCook(order or)
    17       {
    18           Console.WriteLine("服务员将菜{0}送给客户{1}!",or.mealList,or.id,or.customer);
    19           or.customer.Eat();
    20 
    21       }
    22     }
     1 public class Chef//厨师类
     2     {
     3       private order or;
     4       public void GetOrder(order or)
     5       {
     6           this.or = or;
     7       }
     8       public void Cook()
     9       {
    10           Console.WriteLine("厨师烹制:{0}",or.mealList);
    11           Console.WriteLine("制作完毕!");
    12       }
    13       public void SendAlert(waitress wait)
    14       {
    15           Console.WriteLine("厨师提示服务员取菜");
    16           wait.GetOrder(or);
    17       }
    18     }
     1  static void Main(string[] args)
     2         {
     3             //初始化顾客 服务员 厨师
     4             Client wang = new Client();
     5             waitress wait = new waitress();
     6             Chef chef = new Chef();
     7             //初始化菜单
     8             order or = new order();
     9             //设置订了该菜单的顾客
    10             or.customer = wang;
    11             or.id = 100;
    12             or.mealList = "麻辣小龙虾";
    13 
    14             wang.Order(wait, or);
    15             wait.SendOrder(chef);
    16 
    17             chef.Cook();
    18             chef.SendAlert(wait);
    19             wait.TransCook(or);
    20             Console.ReadLine();
    21         }
    22     }
  • 相关阅读:
    js获取多选框选择的值并拼接成字符串
    把不可枚举数组转换成可枚举数组
    js对接图片上传接口
    填数字游戏解题机
    带你深入了解nginx基本登录认证(包含配置步骤)
    高三whk回忆录
    SpringBoot异步任务
    Shell 脚本
    【Ubuntu】知识点及经验
    【Ubuntu】 安装相关
  • 原文地址:https://www.cnblogs.com/aaaaliling/p/8903558.html
Copyright © 2011-2022 走看看