书信息类
package test0328;
public class Book {
private String title;
private double price;
public Book() {
}
public Book(String title,double price) {
this.title = title;
this.price = price;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return this.title;
}
public void setPrice(double price) {
this.price = price;
}
public double getPrice() {
return this.price;
}
}
测试类
package test0328;
import java.util.Scanner;
public class Student {
private String name;
private int birth;
private Book[]book = new Book[10];
public Student() {
}
public Student(String name) {
this.name = name;
}
public Student(String name,int birth,Book book) {
this.name = name;
this.birth = birth;
this.book[0] = book;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public void setBook(Book[]book) {
this.book = book;
}
public Book[] getBook() {
return this.book;
}
public void setBirth(int birth) {
this.birth = birth;
}
public int setBirth() {
return this.birth;
}
public static void main(String[]args) {
Scanner s = new Scanner(System.in);
Book[] book = new Book[2];
book[0] = new Book();
book[0].setTitle("小王子");
book[0].setPrice(28.8);
Student student = new Student("胡梦杰",20030406,book[0]);
book[1] = new Book();
book[1].setTitle("红楼梦");
book[1].setPrice(88.8);
student.setBook(book);
System.out.println("借书人的姓名是:"+student.name+"n"+"出生日期为"+student.birth+"n"+"借书的详细信息:");
for(int i=0;i
}
s.close();
}
}



