public void BorrowerPeople(BookLibrary bl) { //登陆 Console.WriteLine("请输入您的学号/工号:"); string number = @"^5901114\d{3}$"; while (true) { string num = Console.ReadLine(); bool mybool = Regex.IsMatch(num.Trim(), number); if (!mybool) { Console.WriteLine("学号/工号输入错误!"); continue; } break; } Console.WriteLine("请输入您的姓名:"); string myName = Console.ReadLine(); Console.WriteLine("登陆成功!"); //查询书籍 Console.WriteLine("请输入您想要查询的书籍名称:"); string BookName = Console.ReadLine(); int i = 0; i = bl.list.Where(p => p.Name.Contains(BookName)).Count(); Console.WriteLine("您所查询的书籍{0}还有{1}本,", BookName, i); }
static void Main(string[] args) { Console.WriteLine("欢迎进入图书管理系统!"); Console.WriteLine("**********图书管理系统**********"); BookLibrary book = new BookLibrary(); PersonMessage pm = new PersonMessage(); k : Console.WriteLine("请选择你的身份:1.管理员 2.借阅者"); while (true) { string choose = Console.ReadLine(); switch (choose) { case "1": BookManager bm = new BookManager(); bm.ManagerChoose(); break; case "2": Borrower br = new Borrower(); br.BorrowerChoose(); break; default: Console.WriteLine("非法输入!请重新输入"); goto k; //跳转至上面语句a } break; } Console.ReadLine(); }
//借书 public void Borrow(BookLibrary bl) { Console.WriteLine("请输入您需要借阅的书籍:"); string Name = Console.ReadLine(); Console.WriteLine("请输入您需要借阅书籍的数量:"); int count = Convert.ToInt32(Console.ReadLine()); BookFather[] BF = bl.BookBorrow(Name, count); }
//还书 public void Return(BookLibrary bl) { Console.WriteLine("请输入您需要还书的ID:"); string id = Console.ReadLine(); foreach (var item in bl.list) { if (item.ID == id) { Console.WriteLine("{0}已被还,书的编号为{1}", item.Name, item.ID); } } }
static void Main(string[] args) { //创建管理员对象 Management M = new Management(); //创建流动库对象 BookLibrary bl = new BookLibrary(); M.SetLibrary(bl); //展示书籍 bl.Books(); M.AddBook(); M.ShowBook(); //跟借阅者交互 Borrowers B = new Borrowers(); B.BorrowerPeople(bl); //借书 B.Borrow(bl); //还书 B.Return(bl); Console.ReadKey(); }
public void SetLibrary(BookLibrary bl) { this.bl = bl; }