首页 新闻 会员 周边

关于做饭的问题,大家怎么看

2
[已解决问题] 解决于 2013-10-19 07:56

昨天我做好饭等男友回来,吃饭时说了句:“明天给你做好吃的”,吃完饭的时候让他刷碗,把我喜欢的一个碗打碎了,然后不开心,我接着刷碗,他说明天给我做饭,还问我:“你想吃小鸡炖蘑菇还是还是红烧牛肉还是西红柿打卤面.....”(我知道是方便面)

背景交代完毕;问题:

刚刚说今晚让他做饭,我回家歇着打游戏,他不做,他说:“应该先执行之前的 按顺序的解析的  你先说给我做的,所以应该你做  不信你加断点”

我说:“在没有使用的时候 你给一个变量付两次不同的值  一定是使用后面那个的”

 所以今晚谁做饭?

W宁宁的主页 W宁宁 | 小虾三级 | 园豆:522
提问于:2013-10-18 16:14
< >
分享
最佳答案
1

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CookWar
{
    class Person
    {
        public String Name { get; set; }

        /// <summary>
        /// 人品指数
        /// </summary>
        public int RPlevel { get; set; }

        /// <summary>
        /// 承诺要做饭
        /// </summary>
        /// <param name="word"></param>
        public void SayPlan2Cook(String word)
        {
            Console.WriteLine(this.Name + ":" + word);
        }

        public void Cook()
        {
            Console.WriteLine(this.Name + "做了香喷喷的饭");
        }

        public void Wash()
        {
            if (this.RPlevel < 60)
            {
                throw new Exception(this.Name + "打烂了碗");
            }
            else if (this.RPlevel >=60 && this.RPlevel <100)
            {
                throw new Exception(this.Name + "割破了手");
            }
            else
            {
                Console.WriteLine(this.Name + "愉快的洗了碗");
            }
        }
    }
}
View Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CookWar
{
    class CookPlanOperator
    {
        Stack<Person> _workerStack = new Stack<Person>();//洗碗计划,谁后计划洗,谁洗

        public void AddPlan(Person person, String promiseWord)
        {
            person.SayPlan2Cook(promiseWord);
            _workerStack.Push(person);
        }

        public void Cook()
        {
            Person person = _workerStack.Pop();
            if (person != null)
            {
                person.Cook();
            }
            else
            {
                Console.WriteLine("神说:还是泡面吧!");
            }
            _workerStack.Clear();
        }
    }
}
View Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CookWar
{
    class Program
    {
        static void Main(string[] args)
        {
            Person W宁宁 = new Person();
            W宁宁.Name = "W宁宁";
            W宁宁.RPlevel = 100;

            Person WBoyFriend = new Person();
            WBoyFriend.Name = "W宁宁男友";
            WBoyFriend.RPlevel = -100;           

            Console.WriteLine("故事发生在一天晚上.........");

            CookPlanOperator oper = new CookPlanOperator();
            oper.AddPlan(W宁宁, "明天给你做好吃的");
            try
            {
                WBoyFriend.Wash();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                oper.AddPlan(WBoyFriend, "你想吃小鸡炖蘑菇还是还是红烧牛肉还是西红柿打卤面.....");
            }
            Console.WriteLine("第二天.........");
            oper.Cook();

            Console.ReadKey();
        }       
    }
}
View Code
奖励园豆:5
会长 | 专家六级 |园豆:12401 | 2013-10-18 18:19

经典deOOP啊!

峰和日丽 | 园豆:110 (初学一级) | 2013-10-18 22:54

会长大人太有才了,赞一个

W宁宁 | 园豆:522 (小虾三级) | 2013-10-19 07:57
其他回答(7)
0

乐了

iEvent | 园豆:529 (小虾三级) | 2013-10-18 16:31
0

这是做测试吗?

Zery | 园豆:6151 (大侠五级) | 2013-10-18 16:52
1

取决于今晚是debug还是release

dudu | 园豆:31007 (高人七级) | 2013-10-18 17:18
0

显然应该男友做, 碗摔碎了是异常, 所以楼主刷碗转天男友做饭是属于异常处理

黑暗煎饼果子 | 园豆:354 (菜鸟二级) | 2013-10-18 17:21
0

挖墙脚,你可以说你今晚不做,有N多人排队请你吃饭呢。。。。哇咔咔

包拯 | 园豆:9 (初学一级) | 2013-10-18 18:35
0

mumuliang | 园豆:213 (菜鸟二级) | 2013-10-21 09:13
0

哇咔咔  会长大人是女仆

mushishi | 园豆:230 (菜鸟二级) | 2013-10-28 19:27
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册