Exemplo n.º 1
0
 public void OnIlishSell(object source, FishAmountArgs e)
 {
     if ((marketStore.getIlishList().Count - e.amount) >= 0)
     {
         temp  = marketStore.getIlishList().Count;
         temp -= e.amount;
         marketStore.setIlishList(temp);
     }
     else
     {
         Console.WriteLine("Insufficient Fish ! ");
     }
 }
Exemplo n.º 2
0
        public void OnIlishBuy(object source, FishAmountArgs e)
        {
            if ((insFishTank.getIlishList().Count - e.amount) >= 0)
            {
                temp  = insFishTank.getIlishList().Count;
                temp -= e.amount;
                insFishTank.setIlishList(temp);

                temp  = marketStore.getIlishList().Count;
                temp += e.amount;
                marketStore.setIlishList(temp);
            }
            else
            {
                Console.WriteLine("Insufficient fish in fish tank");
            }
        }
Exemplo n.º 3
0
        public void task()
        {
            while (true)
            {
                var market   = new Market();
                var hatchery = new Hatchery();


                Console.WriteLine(" For Rui - 1\n For Katla - 2\n For Ilish - 3\n To Quit - 0\n");
                int fishNo = Convert.ToInt32(Console.ReadLine());

                Console.WriteLine("Enter amount to buy - ");
                int amount = Convert.ToInt32(Console.ReadLine());


                if (fishNo == 1)
                {
                    market.buyEvent += hatchery.OnRuiBuy;
                    market.raiseBuyEvent(amount);
                }
                else if (fishNo == 2)
                {
                    market.buyEvent += hatchery.OnKatlaBuy;
                    market.raiseBuyEvent(amount);
                }
                else if (fishNo == 3)
                {
                    market.buyEvent += hatchery.OnIlishBuy;
                    market.raiseBuyEvent(amount);
                }
                else if (fishNo == 0)
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Invalid Input");
                }

                Console.WriteLine(
                    "All Available Fish -- \n" +
                    "in Market Store   . . . . . . . .   in Fish Tank\n" +
                    "(1) Rui - {0}   . . . . . . . . . .   (1) Rui - {3}\n" +
                    "(2) Katla - {1}   . . . . . . . . .   (2) Katla - {4}\n" +
                    "(3) Ilish - {2}   . . . . . . . . .   (3) Ilish - {5}\n",
                    marketStore.getRuiList().Count, marketStore.getKatlaList().Count, marketStore.getIlishList().Count, insFishTank.getRuiList().Count, insFishTank.getKatlaList().Count, insFishTank.getIlishList().Count);
            }
        }