75 lines
1.6 KiB
Java
75 lines
1.6 KiB
Java
package com.inmind.javabean04;
|
|
/*
|
|
* 最贵的书。
|
|
|
|
* 定义一个图书Book类。
|
|
|
|
- 属性:图书编号,书名,价格,出版日期
|
|
- 构造方法:
|
|
- 无参构造方法,满参构造方法
|
|
- 成员方法:
|
|
- get/set方法
|
|
- showBook方法,输出图书信息
|
|
|
|
* 定义测试类,使用满参构造方法,创建三(多)个Book对象,判断价格最贵的图书(存放书的数组的遍历),并输出图书信息。
|
|
|
|
*/
|
|
public class Book {
|
|
private String bid;
|
|
private String bName;
|
|
private double price;
|
|
private String date;
|
|
|
|
public Book() {
|
|
}
|
|
|
|
public Book(String bid, String bName, double price, String date) {
|
|
this.bid = bid;
|
|
this.bName = bName;
|
|
this.price = price;
|
|
this.date = date;
|
|
}
|
|
|
|
public String getBid() {
|
|
return bid;
|
|
}
|
|
|
|
public void setBid(String bid) {
|
|
this.bid = bid;
|
|
}
|
|
|
|
public String getbName() {
|
|
return bName;
|
|
}
|
|
|
|
public void setbName(String bName) {
|
|
this.bName = bName;
|
|
}
|
|
|
|
public double getPrice() {
|
|
return price;
|
|
}
|
|
|
|
public void setPrice(double price) {
|
|
this.price = price;
|
|
}
|
|
|
|
public String getDate() {
|
|
return date;
|
|
}
|
|
|
|
public void setDate(String date) {
|
|
this.date = date;
|
|
}
|
|
|
|
|
|
public void showBook() {
|
|
System.out.println("图书信息{" +
|
|
"图书编号='" + bid + '\'' +
|
|
", 书名='" + bName + '\'' +
|
|
", 价格=" + price +
|
|
", 日期='" + date + '\'' +
|
|
'}');
|
|
}
|
|
}
|