📄 cart.java
字号:
/*
* Created on 2005-3-11
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package shopping;
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class Cart {
private String[] goodsName;
private String[] goodsPrice;
private String[] goodsNumber;
private String total;
/**
* @return Returns the goodsName.
*/
public String[] getGoodsName() {
return goodsName;
}
/**
* @param goodsName
* The goodsName to set.
*/
public void setGoodsName(String[] goodsName) {
this.goodsName = goodsName;
}
/**
* @return Returns the goodsNumber.
*/
public String[] getGoodsNumber() {
return goodsNumber;
}
/**
* @param goodsNumber
* The goodsNumber to set.
*/
public void setGoodsNumber(String[] goodsNumber) {
this.goodsNumber = goodsNumber;
}
/**
* @return Returns the goodsPrice.
*/
public String[] getGoodsPrice() {
return goodsPrice;
}
/**
* @param goodsPrice
* The goodsPrice to set.
*/
public void setGoodsPrice(String[] goodsPrice) {
this.goodsPrice = goodsPrice;
}
/**
* @return Returns the total.
*/
public String getTotal() {
return total;
}
/**
* @param total
* The total to set.
*/
public void setTotal(String total) {
this.total = total;
}
/**
*
*/
public void computeTotal() {
double price = 0;
for (int i = 0; i < getGoodsNumber().length; i++) {
price += (Integer.parseInt(getGoodsNumber()[i]))
* (Double.parseDouble(getGoodsPrice()[i]));
}
setTotal(price + "");
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
public String toString() {
StringBuffer str = new StringBuffer();
for (int i = 0; i < getGoodsNumber().length; i++) {
str.append("Name==" + getGoodsName()[i] + "\n");
str.append("Price==" + getGoodsPrice()[i] + "\n");
str.append("Number==" + getGoodsNumber()[i] + "\n");
}
str.append("Total==" + getTotal());
return str.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -