예제 #1
0
        private static void Main(string[] args)
        {
            Student s3 = new Student("王五", null);

            Student s1 = new Student("张三", s3);
            Student s2 = new Student("李四", s1);

            Book b1 = new Book("赵六");
            s2.CheckBook(b1);

            Console.ReadLine();
        }
예제 #2
0
 public void CheckBook(Book book)
 {
     if (_name == book.Name)
     {
         Console.WriteLine("{0}:这是我的作业本,我收下了", _name);
     }
     else
     {
         if (_nextStudent != null)
         {
             Console.WriteLine("{0}:这不是我的作业本,我传给下一位同学了", _name);
             _nextStudent.CheckBook(book);
         }
         else
         {
             Console.WriteLine("{0}:这不是我的作业本,但是后面没人了,作业本没人要了", _name);
         }
     }
 }