示例#1
0
        /// <summary>
        /// Writes a list of all specials available in the database.
        /// </summary>
        /// <returns></returns>
        private static string WriteSpecials()
        {
            StringBuilder builder = new StringBuilder();

            int h = 0;
            int i = Database_API.GetSpecialsCount();

            while (h < i)
            {
                Special item = Database_API.GetSpecial(h);
                builder.Append(DisplayOrganizer.AddEntry(item.itemAffected, SPACING_NAME));
                builder.AppendLine(FormatSP(item, SPACING_NAME));
                h++;
            }
            return(builder.ToString());
        }
示例#2
0
        /// <summary>
        /// Writes a list of all items available in the database.
        /// </summary>
        /// <returns>A string of all items in the database.</returns>
        private static string WriteItems()
        {
            StringBuilder builder = new StringBuilder();

            int h = 0;
            int i = Database_API.GetItemCount();

            while (h < i)
            {
                Item item = Database_API.GetItem(h);
                builder.Append(DisplayOrganizer.AddEntry(item.name, SPACING_NAME));
                builder.Append(DisplayOrganizer.AddEntry(item.price.ToString(), SPACING_VALUE));
                builder.AppendLine(DisplayOrganizer.AddMark(item.priceByWeight));
                h++;
            }
            return(builder.ToString());
        }
示例#3
0
        private static void WritePromptHelp()
        {
            Console.WriteLine("We have the following selection:");
            Console.Write(DisplayOrganizer.AddEntry("Item Name", 30));
            Console.Write(DisplayOrganizer.AddEntry("Price", 10));
            Console.WriteLine("Sell By Weight");
            Console.WriteLine(WriteItems());
            Console.WriteLine("And the following specials:");
            Console.WriteLine(WriteSpecials());

            Console.WriteLine("Command List (ignore the brackets: they're there to make things look neat.");
            Console.WriteLine("Note that all operation commands (not the print ones) have their own prompts.");
            Console.WriteLine("[a] add a purchase.");
            Console.WriteLine("[r] remove a purchase.");
            Console.WriteLine("[i] add an item (to the database).");
            Console.WriteLine("[s] add a special to the database.");
            Console.WriteLine("[h] print the store's goods/specials and this command list again.");
            Console.WriteLine("[t] print the total of our purchase.");
            Console.WriteLine("[x] print the receipt of our purchases.");
            Console.WriteLine("[q] quit this program.");
        }
        /// <summary>
        /// Displays the receipt of this purchase.
        /// </summary>
        /// <param name=""></param>
        public string GetReceipt(bool showOrdering, bool showSpecials)
        {
            StringBuilder builder = new StringBuilder();
            int           counter = 0;

            foreach (ItemInCart item in listOfItems)
            {
                if (showOrdering)
                {
                    counter++;
                    builder.Append(DisplayOrganizer.AddBrackets(counter));
                }
                //Displays the item and its price.
                builder.Append(DisplayOrganizer.AddEntry(item.GetName(), 30));
                builder.AppendLine(DisplayOrganizer.AddEntry(item.GetOriginalPrice().ToString(), 0));
                //Displays the special and its affects.
                if (showSpecials && item.isDiscounted)
                {
                    builder.AppendLine(DisplayOrganizer.AddSpecial(item.special_ID, 30));
                }
            }

            return(builder.ToString());
        }