//封装数据
package com.pictice;
public class Book {
String bookName;
int number;
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
@Override
public String toString() {
return "Book [bookName=" + bookName + ", number=" + number + "]";
}
}
//写入数据
package com.pictice;
public class IBook extends Book {
String bookName;
int number;
public IBook(int number, String bookName) {
// TODO Auto-generated constructor stub
Book book = new Book();
book.setBookName(bookName);
book.setNumber(number);
this.number = book.getNumber();
this.bookName = book.getBookName();
}
@Override
public String toString() {
return "IBook [bookName=" + bookName + ", number=" + number + "]";
}
}
//获取数据(无法获取)
package com.pictice;
import com.pictice.Book;
public class GetBook extends Book{
int number;
String nameBook;
public GetBook() {
// TODO Auto-generated constructor stub
//Book book=new Book();
this.number=super.getNumber();
this.nameBook=super.getBookName();
}
@Override
public String toString() {
return "GetBook [number=" + number + ", nameBook=" + nameBook + "]";
}
}