📄 sale.java
字号:
public class Sale {
/**
* Constructor
* @param cardName String
*/
public Sale(String stuffName,String cardCode,int quantity) throws Exception {
saleCard(stuffName,cardCode,quantity);
}
/**
* saleCard
*
* @param stuffName String
* @param cardName String
* @param quantity int
*/
private void saleCard(String stuffName, String cardCode, int quantity) throws Exception{
if(stuffName==null||"".equals(stuffName)){
throw new Exception("Please insert the name of the stuff");
}
if(cardCode==null||"".equals(cardCode)){
throw new Exception("Please insert the index of the card");
}
Card c = CardList.getCard(cardCode);
int num = c.getQuantity();
if(quantity>num){
throw new Exception("Not enough cards");
}
if(quantity<=0){
throw new Exception("The quantity must be larger then 0");
}
try {
SaleList.saleCard(stuffName, cardCode, quantity);
}
catch (Exception ex) {
throw ex;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -