//DateFormat format = new SimpleDateFormat("MMMM d, yyyy"); public void run() { bool exitMenu = false; bool exitBookMenu = false; bool exitMagMenu = false; bool exitDiscMenu = false; bool exitTicketMenu = false; //Scanner input = new Scanner(System.in); // Main menu loop while (!exitMenu) { exitMenu = false; exitBookMenu = false; exitMagMenu = false; exitDiscMenu = false; exitTicketMenu = false; theLine(); // Main Menu Console.WriteLine("\nChoose a Publication Type\n\n" + "1. Book\n" + "2. Magazine\n" + "3. Disc Magazine\n" + "4. Ticket\n\n" + "Enter Selection: "); int menuSelection = 0; menuSelection = Convert.ToInt32(Console.ReadLine()); switch (menuSelection) { case 1: // Book menu while (!exitBookMenu) { Console.WriteLine("\nBooks\n\n" + "1. Add a Book\n" + "2. Edit a Book\n" + "3. Delete a Book\n" + "4. Sell a Book\n\n" + "Enter Selection: "); int menuBookSelection = 0; menuBookSelection = Convert.ToInt32(Console.ReadLine()); switch (menuBookSelection) { case 1: boolBook = true; AddAPublication(); break; case 2: editABook(); break; case 3: deleteABook(); break; case 4: sellABook(); break; case -1: exitBookMenu = true; break; default: Console.WriteLine("Please enter a valid choice."); break; } } break; case 2: // Magazine Menu while (!exitMagMenu) { Console.WriteLine("\nMagazines\n\n" + "1. Add a Magazine\n" + "2. Edit a Magazine\n" + "3. Delete a Magazine\n" + "4. Sell a Magazine\n\n" + "Enter Selection: "); int menuMagazineSelection = 0; menuMagazineSelection = Convert.ToInt32(Console.ReadLine()); switch (menuMagazineSelection) { case 1: boolMagazine = true; AddAPublication(); break; case 2: editAMag(); break; case 3: deleteAMag(); break; case 4: sellAMag(); break; case -1: exitMagMenu = true; break; default: Console.WriteLine("Please enter a valid choice."); break; } } break; case 3: // Disc Mag menu while (!exitDiscMenu) { Console.WriteLine("\nDisc Magazines\n\n" + "1. Add a Disc Magazine\n" + "2. Edit a Disc Magazine\n" + "3. Delete a Disc Magazine\n" + "4. Sell a Disc Magazine\n\n" + "Enter Selection: "); int menuDiscMagazineSelection = 0; menuDiscMagazineSelection = Convert.ToInt32(Console.ReadLine()); switch (menuDiscMagazineSelection) { case 1: boolDiscMag = true; AddAPublication(); break; case 2: editADisc(); break; case 3: deleteADiscMag(); break; case 4: sellADiscMag(); break; case -1: exitDiscMenu = true; break; default: Console.WriteLine("Please enter a valid choice."); break; } } break; case 4: // Disc Mag menu while (!exitTicketMenu) { Console.WriteLine("\nTickets\n\n" + "1. Sell a Ticket\n" + "Enter Selection: "); int menuDiscMagazineSelection = 0; menuDiscMagazineSelection = Convert.ToInt32(Console.ReadLine()); switch (menuDiscMagazineSelection) { case 1: Ticket ticket = new Ticket(); //ticket.sellCopy(); //CashTill sell = new CashTill(); sell.sellItem(ticket); sell.showTotal(); break; case -1: exitTicketMenu = true; break; default: Console.WriteLine("Please enter a valid choice."); break; } } break; case -1: exitMenu = true; break; default: Console.WriteLine("Please enter a valid choice."); break; } } Environment.Exit(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); }