问题:
![1587112553310343.png W~4J`0$8J]I{FT}XR7FIN`7.png](https://www.itbaizhan.cn/ueditor/php/upload/image/20200417/1587112553310343.png)
老师,最后一问如何解决呢。
代码:
public class Store {
private int id;
private String name;
private String number;
private double price;
private double discount;
private double sale_price;
public Store(int id, String name, String number, double price, double discount) {
this.id = id;
this.name = name;
this.number = number;
this.price = price;
this.discount = discount;
}
public String toString(){
return "["+id+","+name+","+number+","+price+"discount"+"]";
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public double getDiscount() {
return discount;
}
public void setDiscount(double discount) {
this.discount = discount;
}
public double getSale_price(double m) {
if (m<(this.price*this.discount)){
System.out.println(this.name);
}else {
System.out.println("这个商品价格太低了");
}
return m;
}
public void setSale_price(double sale_price) {
this.sale_price = sale_price;
}
public static void main(String[] args) {
Store[]stores={new Store(1,"baizhan_mouse","BZ_001",99,0.9) ,
new Store(2,"doll","WO_102",403.00,0.7),
new Store(3,"java","BK_001",89.00,0.8),
new Store(4,"suit","GQ_XF_12",700.00,0.5),
new Store(5,"Mi_phone","DM_PH_13",900.00,0.3)};
for (int t=0;t<stores.length;t++){
System.out.println(stores[t]);
}
//System.out.println(Arrays.toString(stores));
}
}