publicclassComplex{
publicstaticvoidmain(String[]args){
/*bx书馆开馆*/
Borrow.open();
/*老师太妃糖来借了十六本书*/
Teachertaifeitang=newTeacher();
taifeitang.BorrowBooks();
taifeitang.setBorrowBooks(16);
/*学生肖博来还了九十五本书*/
StudentXiaobo=newStudent();
Xiaobo.ReturnBooks();
Xiaobo.setReturnBooks(95);
/*图书馆闭馆*/
Borrow.close();
}
}
//Borrow接口
interfaceBorrow{
publicstaticvoidopen(){
System.out.println("各位果龟请注意,bx图书馆开馆了==+!");//开馆
}
publicstaticvoidclose(){//闭馆
System.out.println("果龟早点睡,小心秃头==+!");
}
publicdefaultvoidBorrowBooks(){
System.out.println("欢迎这位bxg=0=!");//借书
}
publicdefaultvoidReturnBooks(){
System.out.println("你确定好了还书吗?小心学校搬走了!");//还书
}
}
//Library抽象类
abstractclassLibrary{
publicstaticintnum=14823;//设置图书馆藏书有一万四千八百二十三册
publicabstractvoidsetBorrowBooks(intn);
publicabstractvoidsetReturnBooks(intn);
}
//Teacher类:表示老师来借书
classTeacherextendsLibraryimplementsBorrow{
//设置要借多少书
@Override
publicvoidsetBorrowBooks(intn){
num=num-n;
System.out.println("糖糖老师借走了"+n+"本书,图书馆剩余"+num+"本书。");
}
@Override
publicvoidsetReturnBooks(intn){
num=num+n;
System.out.println("糖糖老师归还了"+n+"本书,图书馆剩余"+num+"本书。");
}
}
//Student类:表示学生来借书
classStudentextendsLibraryimplementsBorrow{
@Override
publicvoidsetBorrowBooks(intn){
num=num-n;
System.out.println("果龟借走了"+n+"本书,图书馆剩余"+num+"本书。");
}
@Override
publicvoidsetReturnBooks(intn){
num=num+n;
System.out.println("果龟归还了"+n+"本书,图书馆剩余"+num+"本书。");
}