private static void ReceiptMath(Buyer buyer, bool didTip)
        {
            decimal receiptTotal = GetMoneyAmountInputs("Enter total for this receipt: $", true);
            decimal tipAmount    = 0;

            if (didTip)
            {
                tipAmount = GetMoneyAmountInputs("Please enter tip amount: $", true);
            }
            buyer.HoldReceipt(new Receipt(receiptTotal, tipAmount));

            TextMenu <Buyer> menu            = new TextMenu <Buyer>();
            Roommate         roomieSelection = buyer.Name;
            bool             done            = false;

            foreach (Roommate r in Enum.GetValues(typeof(Roommate)))
            {
                menu.AddItem(new TextMenuItem <Buyer>($"{r} bought stuff", (p) => { roomieSelection = r; }));
            }
            menu.AddItem(new TextMenuItem <Buyer>($"Receipt complete: Add to {buyer.Name} total", (p) => { done = true; }));
            while (!done)
            {
                int i = menu.GetMenuChoiceFromUser() - 1;
                menu.Run(i, buyer);
                if (done)
                {
                    break;
                }
                GetIndividualPurchases(buyer, roomieSelection);
            }

            buyer.AddReceiptToTotals();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            WriteLine("R E C E I P T");
            WriteLine("================================================");

            foreach (Roommate name in Enum.GetValues(typeof(Roommate)))
            {
                household.Add(new Buyer(name));
            }

            bool             done        = false;
            TextMenu <Buyer> mainMenu    = new TextMenu <Buyer>();
            Buyer            buyerSelect = null;

            foreach (Buyer b in household)
            {
                mainMenu.AddItem(new TextMenuItem <Buyer>($"Do {b.Name} receipts", (p) => { buyerSelect = b; }));
            }
            mainMenu.AddItem(new TextMenuItem <Buyer>("Show Totals", (p) => { ShowTotals(); }));
            mainMenu.AddItem(new TextMenuItem <Buyer>("Quit", (p) => { done = true; }));

            while (!done)
            {
                int i = mainMenu.GetMenuChoiceFromUser() - 1;
                mainMenu.Run(i, buyerSelect);
                if (i >= household.Count)
                {
                    continue;
                }
                else
                {
                    Buyer.BuyerMenu(buyerSelect);
                }
            }
        }
        public void AddOption(string caption)
        {
            itemCount++;

            ConsoleOptionPageItem item = new ConsoleOptionPageItem(caption, itemCount.ToString());

            var textMenuItem = item.GetInstance() as TextMenuItem;

            textMenuItems.Add(item);

            textMenu.AddItem(textMenuItem);
        }
        public TextMenu <Player> GetMenu()
        {
            TextMenu <Player> menu = new TextMenu <Player>();

            foreach (Direction direction in Pathways.Keys)
            {
                menu.AddItem(new TextMenuItem <Player>($"Go {direction}",
                                                       (p) => { p.MoveTo(Pathways[direction]); }));
            }
            foreach (TextMenuItem <Player> menuitem in MenuItems)
            {
                menu.AddItem(menuitem);
            }
            if (Resident != null && Resident.Health > 0 && Resident.CanFight)
            {
                menu.AddItem(new TextMenuItem <Player>($"Fight {Resident.Name}", GameActions.PlayerAttacks));
            }
            return(menu);
        }
Esempio n. 5
0
        public static void BuyerMenu(Buyer buyer)
        {
            if (buyer == null)
            {
                throw new ArgumentNullException("Buyer can not be null");
            }

            bool             done = false;
            TextMenu <Buyer> menu = new TextMenu <Buyer>();

            menu.AddItem(new TextMenuItem <Buyer>($"{buyer.Name}: Normal receipt", ReceiptActions.BasicReceipt));
            menu.AddItem(new TextMenuItem <Buyer>($"{buyer.Name}: Receipt with tip", ReceiptActions.ReceiptWithTip));
            //DELETE ME: potential add - receipt with only one other person?
            // also receipt with alcohol tax ?? or with alcohol taxed purchases
            menu.AddItem(new TextMenuItem <Buyer>("Back to main menu", (p) => { done = true; }));

            while (!done)
            {
                int i = menu.GetMenuChoiceFromUser() - 1;
                menu.Run(i, buyer);
            }
        }
Esempio n. 6
0
        private TextMenu <Action> createMainMenu()
        {
            var ret = new TextMenu <Action>();

            ret.AddItem("Debug", delegate { new VSDebugAttacher().AttachToVisualStudio(); });
            ret.AddItem("Load/Save", showPersistence);
            ret.AddItem("Clean", cleanData);
            ret.AddItem("Reset", resetData);
            ret.AddItem("Select test [Press F5]", delegate { });
            ret.AddItem("Exit DONT PRESS", OnExit);

            return(ret);
        }