/// <summary> /// a member borrows a tool from the system /// </summary> /// <param name="aMember"> member who borrows a tool </param> /// <param name="aTool"> tool gets borrowed </param> /// <returns></returns> public bool borrowTool(Member aMember, Tool aTool) { if (aTool.AvailableQuantity > 0) { if (aMember.Tools == null || aMember.Tools.Length < 3) { aMember.addTool(aTool); aTool.addBorrower(aMember); borrowedTools.Add(aTool); // add the borrowed tool to the list borrowedTools = borrowedTools.Distinct().ToList(); // remove duplicate tools return(true); } else { Console.WriteLine("\nYou have borrowed 3 tools, please return some of them before borrowing."); Console.WriteLine("Press any key to go back. "); Console.ReadKey(); } } else { Console.WriteLine("\nTool unavailable, please come back later."); Console.WriteLine("Press any key to go back. "); Console.ReadKey(); } return(false); }
// logic implemented to borrow a tool by the member public void borrowTool(Member aMember, Tool aTool) { --aTool.AvailableQuantity; aMember.addTool(aTool); }