You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package jichuti1 ;
import java.time.LocalDate ;
public class BasicTest {
public static void main ( String [ ] args ) {
// 创建图书类别
BookCategory category = new BookCategory ( "C001" , "计算机科学" ) ;
// 创建图书
Book book1 = new Book ( "B001" , "Java编程思想" , "Bruce Eckel" ) ;
Book book2 = new Book ( "B002" , "数据结构" , "严蔚敏" ) ;
// 建立聚合关系
category . addBook ( book1 ) ;
category . addBook ( book2 ) ;
// 创建读者
Reader reader = new Reader ( "R001" , "张三" ) ;
// 预约图书( book1已被借出)
book1 . setAvailable ( false ) ;
Reservation reservation = reader . reserveBook ( book1 , LocalDate . now ( ) ) ;
if ( reservation ! = null ) {
System . out . println ( reader . getName ( ) + " 成功预约图书:" + book1 . getTitle ( ) ) ;
System . out . println ( "预约ID: " + reservation . getReservationId ( ) ) ;
}
}
}