📄 cartitem.java
字号:
package wyf;
import java.io.Serializable;
//这个类代表一种商品的情况
public class CartItem implements Serializable
{
private String id ; // 商品的编号
private String title; // 商品的名称
private double price; // 商品的价格
private int qty; // 顾客要购买的数量
public CartItem()
{
}
/**
* 这个构造器构造一种商品
*
* @param id 商品的编号
* @param title 商品的名称
* @param price 商品的价格
* @param qty 顾客要购买的数量
*/
public CartItem(String id, String title, double price, int qty)
{
this.id = id;
this.title = title;
this.price = price;
this.qty = qty;
}
//返回商品的名称
public String getTitle()
{
return title;
}
//返回商品的id
public String getId()
{
return id;
}
//返回商品的价格
public double getPrice()
{
return price;
}
//返回所购商品的数量
public int getQty()
{
return qty;
}
//设定所购商品的数量
public void setQty(int qty)
{
this.qty=qty;
}
//返回商品的所有情况
public String toString()
{
String result = id + "-->" + title + "-->" + price+"-->"+qty;
return result;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -