public static void RunCommand(int[] selection) { int staff, menuSelection1, menuSelection2; int[] changeTool; bool remove, noQuantity; iTool returnedTool; string toolTypeStr; menuSelection1 = 0; staff = menuSelection2 = 1; iToolLibrarySystem funcs = new ToolLibrarySystem(); if (selection[menuSelection1] == staff)//staff { switch (selection[menuSelection2]) { case (int)StaffCommands.AddNewTool: navigateToolMenu(out toolTypeStr, funcs); returnedTool = CreateNewTool(); funcs.add(returnedTool); funcs.displayTools(toolTypeStr); break; case (int)StaffCommands.AddExisitingTool: navigateToolMenu(out toolTypeStr, funcs); changeTool = PickTool(); if (changeTool != null) { returnedTool = currentToolType.toArray()[changeTool[0] - 1]; funcs.add(returnedTool, changeTool[1]); } funcs.displayTools(toolTypeStr); break; case (int)StaffCommands.RemoveTool: navigateToolMenu(out toolTypeStr, funcs); bool removeExisting = true; changeTool = PickTool(removeExisting); if (changeTool != null) { returnedTool = currentToolType.toArray()[changeTool[0] - 1]; if (returnedTool.Quantity == changeTool[1]) { funcs.delete(returnedTool); } else { funcs.delete(returnedTool, changeTool[1]); } } funcs.displayTools(toolTypeStr); break; case (int)StaffCommands.RegisterMember: printMembers(); iMember newMember = CreateMember(); funcs.add(newMember); printMembers(); Console.Write("Press any Key to continue..."); Console.ReadKey(); break; case (int)StaffCommands.RemoveMember: printMembers(); iMember removeMember = PickMember(); funcs.delete(removeMember); printMembers(); Console.Write("Press any Key to continue..."); Console.ReadKey(); break; case (int)StaffCommands.ContactNumMember: getContact(); break; default: Console.WriteLine("Error: switch failed :("); break; } } else //member { switch (selection[menuSelection2]) { case (int)MemberCommands.DisplayAllToolsType: navigateToolMenu(out toolTypeStr, funcs); break; case (int)MemberCommands.BorrowTool: navigateToolMenu(out toolTypeStr, funcs); remove = false; noQuantity = true; changeTool = PickTool(remove, noQuantity); if (changeTool != null) { funcs.borrowTool(Program.aCollection.CurrentMember, currentToolType.toArray()[changeTool[0] - 1]); } funcs.displayTools(toolTypeStr); break; case (int)MemberCommands.ReturnTool: funcs.displayBorrowingTools(Program.aCollection.CurrentMember); remove = false; noQuantity = true; Member replace = (Member)Program.aCollection.CurrentMember; changeTool = PickTool(remove, noQuantity, Program.aCollection.CurrentMember.Tools.Length); if (changeTool != null) { funcs.returnTool(Program.aCollection.CurrentMember, replace.ToolsBorrowed[changeTool[0] - 1]); } funcs.displayBorrowingTools(Program.aCollection.CurrentMember); break; case (int)MemberCommands.ListToolsRenting: funcs.displayBorrowingTools(Program.aCollection.CurrentMember); break; case (int)MemberCommands.DisplayTopThree: funcs.displayTopTHree(); break; default: Console.WriteLine("Error: switch failed :("); break; } } }
static void MemberLogin(ToolLibrarySystem toolLibrarySystem) { Console.Write("Enter your first name: "); string firstName = Console.ReadLine(); Console.WriteLine(""); Console.Write("Enter your last name: "); string lastname = Console.ReadLine(); Console.WriteLine(""); Console.Write("Enter your contact number: "); string contactNumber = Console.ReadLine(); Console.WriteLine(""); Console.Write("Enter your pin: "); string pin = Console.ReadLine(); Console.WriteLine(""); Member tempMember = new Member(firstName, lastname, contactNumber, pin); if (toolLibrarySystem.registerMembers.search(tempMember) == true) { toolLibrarySystem.currentUser = tempMember; Console.Clear(); Console.WriteLine("=========Member menu=========="); Console.WriteLine("1. Display all the tools of a tool type"); Console.WriteLine("2. Borrow a tool"); Console.WriteLine("3. Return a tool"); Console.WriteLine("4. List all the tools that I am renting"); Console.WriteLine("5. Display top three (3) most frequentely rented tools"); Console.WriteLine("0. Return to main menu"); Console.WriteLine("==============================="); Console.WriteLine(""); Console.WriteLine("Please Make a selection (1-6, or 0 to return to the main menu):"); string myoption; myoption = Console.ReadLine(); switch (myoption) { case "1": DisplayAllTool(toolLibrarySystem); break; case "2": BrrowingTools(toolLibrarySystem); break; case "3": ReturningTools(toolLibrarySystem); Exit(); break; case "4": Exit(); break; case "5": toolLibrarySystem.displayTopTHree(); MainMenu(toolLibrarySystem); Exit(); break; case "0": MainMenu(toolLibrarySystem); break; } } else { Console.WriteLine("Invalid member details. Please try again"); MemberLogin(toolLibrarySystem); } }