public void OnRuiSell(object source, FishAmountArgs e) { if ((marketStore.getRuiList().Count - e.amount) >= 0) { temp = marketStore.getRuiList().Count; temp -= e.amount; marketStore.setRuiList(temp); } else { Console.WriteLine("Insufficient Fish ! "); } }
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); } }
public void OnRuiBuy(object source, FishAmountArgs e) { if ((insFishTank.getRuiList().Count - e.amount) >= 0) { Console.WriteLine("rui buy"); temp = insFishTank.getRuiList().Count; temp -= e.amount; insFishTank.setRuiList(temp); temp = marketStore.getRuiList().Count; temp += e.amount; marketStore.setRuiList(temp); } else { Console.WriteLine("Insufficient fish in fish tank"); } }