Ejemplo n.º 1
0
        static int Sell(int choice, string Pub, CashTill Sales)
        {
            int counter;

            if (Pub == "Book")
            {
                if (Books.Count < 1)
                {
                    Console.WriteLine("There are currently no Books in the System.");
                    return(choice = -1);
                }
                Console.WriteLine("\nHere is a list of the books: \n");

                for (counter = 0; counter < Books.Count; counter++)
                {
                    Console.WriteLine("\n" + ((counter + 1) + ". ") + Books[counter].Title);
                }
                Console.WriteLine("\n ----------------");

                Console.WriteLine("\nEnter the book number to sell: ");
                counter = Convert.ToInt32(Console.ReadLine());
                Sales.sellItem(Books[counter - 1], Pub);
            }
            else if (Pub == "Magazine")
            {
                if (Mags.Count < 1)
                {
                    Console.WriteLine("There are currently no Magazines in the System.");
                    return(choice = -1);
                }
                Console.WriteLine("\nHere is a list of the magazines: \n");

                for (counter = 0; counter < Mags.Count; counter++)
                {
                    Console.WriteLine("\n" + ((counter + 1) + ". ") + Mags[counter].Title);
                }
                Console.WriteLine("\n ----------------");

                Console.WriteLine("\nEnter the magazine number to sell: ");
                counter = Convert.ToInt32(Console.ReadLine());
                Sales.sellItem(Mags[counter - 1], Pub);
            }
            else if (Pub == "Ticket")
            {
                if (Tickz.Count < 1)
                {
                    Console.WriteLine("There are currently no Tickets in the System.");
                    return(choice = -1);
                }
                Console.WriteLine("\nHere is a list of the Tickets: \n");

                for (counter = 0; counter < Tickz.Count; counter++)
                {
                    Console.WriteLine("\n" + ((counter + 1) + ". ") + Tickz[counter].Description);
                }
                Console.WriteLine("\n ----------------");

                Console.WriteLine("\nEnter the Ticket number to sell: ");
                counter = Convert.ToInt32(Console.ReadLine());
                Sales.sellItem(Tickz[counter - 1], Pub);
            }
            return(choice = -1);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            CashTill Sales = new CashTill();

            Book book = new Book();

            book.Author = "Thomas Taylor";
            book.Title  = "Java";
            book.Copies = 12;
            book.Price  = 100;

            Book book1 = new Book();

            book1.Author = "Thomas Taylor jr";
            book1.Title  = "Linux";
            book1.Copies = 12;
            book1.Price  = 100;


            Magazine mag = new Magazine();

            mag.Title     = "Yessir";
            mag.OrderQty  = 10;
            mag.Price     = 19.99;
            mag.CurrIssue = "08-2017";

            Magazine mag1 = new Magazine();

            mag1.Title    = "Yesmaam";
            mag1.OrderQty = 10;
            mag1.Price    = 19.99;

            Books.Add(book);
            Books.Add(book1);
            Mags.Add(mag);
            Mags.Add(mag1);

            int    choice  = -1;
            int    choice1 = -1;
            string Pub;



            while (choice < 0)
            {
                Console.Write("--------Main--------" +
                              "\n1. Books" +
                              "\n2. Magazines" +
                              "\n3. Tickets" +
                              "\n4. Checkout" +
                              "\n5. Exit \n");
                choice = Convert.ToInt32(Console.ReadLine());

                switch (choice)
                {
                case 1:
                    Console.WriteLine("\n1. Add A Book" +
                                      "\n2. Edit A Book" +
                                      "\n3. Delete A Book" +
                                      "\n4. Sell A Book" +
                                      "\n5. Return to Main Menu" +
                                      "\n What would you like to do?");
                    choice1 = Convert.ToInt32(Console.ReadLine());

                    Pub = "Book";
                    do
                    {
                        // switch statement to control which option the user chooses.
                        switch (choice1)
                        {
                        case 1:
                            choice = Add(choice1, Pub);
                            break;

                        case 2:
                            choice = Edit(choice1, Pub);
                            break;

                        case 3:
                            choice = Delete(choice1, Pub);
                            break;

                        case 4:
                            choice = Sell(choice1, Pub, Sales);
                            break;

                        case 5: break;
                        }
                    }while (choice != -1);
                    break;

                case 2:
                    Console.WriteLine("\n1. Add A Magazine" +
                                      "\n2. Edit A Magazine" +
                                      "\n3. Delete A Magazine" +
                                      "\n4. Sell A Magazine" +
                                      "\n5. Return to Main Menu" +
                                      "\n What would you like to do?");
                    choice1 = Convert.ToInt32(Console.ReadLine());

                    Pub = "Magazine";
                    do
                    {
                        // switch statement to control which option the user chooses.
                        switch (choice1)
                        {
                        case 1:
                            choice = Add(choice1, Pub);
                            break;

                        case 2:
                            choice = Edit(choice1, Pub);
                            break;

                        case 3:
                            choice = Delete(choice1, Pub);
                            break;

                        case 4:
                            choice = Sell(choice1, Pub, Sales);
                            break;

                        case 5: break;
                        }
                    }while (choice != -1);
                    break;

                case 3:
                    Console.WriteLine("\n1. Add A Ticket" +
                                      "\n2. Edit A Ticket" +
                                      "\n3. Delete A Ticket" +
                                      "\n4. Sell A Ticket" +
                                      "\n5. Return to Main Menu" +
                                      "\n What would you like to do?");
                    choice1 = Convert.ToInt32(Console.ReadLine());

                    Pub = "Ticket";
                    do
                    {
                        // switch statement to control which option the user chooses.
                        switch (choice1)
                        {
                        case 1:
                            choice = Add(choice1, Pub);
                            break;

                        case 2:
                            choice = Edit(choice1, Pub);
                            break;

                        case 3:
                            choice = Delete(choice1, Pub);
                            break;

                        case 4:
                            choice = Sell(choice1, Pub, Sales);
                            break;

                        case 5: break;
                        }
                    }while (choice != -1);
                    break;

                case 4:
                    Console.WriteLine("Currently out of order");
                    break;

                case 5: break;
                }
            }
        }