1700456183
public interface IBook{
1700456184
1700456185
//书籍有名称
1700456186
1700456187
public String getName();
1700456188
1700456189
//书籍有售价
1700456190
1700456191
public int getPrice();
1700456192
1700456193
//书籍有作者
1700456194
1700456195
public String getAuthor();
1700456196
1700456197
}
1700456198
1700456199
目前书店只出售小说类书籍,小说类如代码清单6-2所示。
1700456200
1700456201
代码清单6-2 小说类
1700456202
1700456203
public class NovelBook implements IBook{
1700456204
1700456205
//书籍名称
1700456206
1700456207
private String name;
1700456208
1700456209
//书籍的价格
1700456210
1700456211
private int price;
1700456212
1700456213
//书籍的作者
1700456214
1700456215
private String author;
1700456216
1700456217
//通过构造函数传递书籍数据
1700456218
1700456219
public NovelBook(String_name,int_price,String_author){
1700456220
1700456221
this.name=_name;
1700456222
1700456223
this.price=_price;
1700456224
1700456225
this.author=_author;
1700456226
1700456227
}
1700456228
1700456229
//获得作者是谁
1700456230
1700456231
public String getAuthor(){
1700456232
[
上一页 ]
[ :1.700456183e+09 ]
[
下一页 ]