📄 calculatefee.java~4~
字号:
package text;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2008</p>
*
* <p>Company: </p>
*
* @author shanshan
* @version 1.0
*/
public class CalculateFee {
public CalculateFee() {
}
public static UpdataTable UseComputerFee(Record rec) {
RecordDAO dao = new RecordDAO();
UpdataTable result = dao.getStopCompouter(rec);
Record record = result.getRecord();
Card card = result.getCard();
//计算本次上机的钱
int fee = calFee(record.getBeginTime(), record.getEndTime());
record.setFee(fee);
int balance = card.getBalance()-fee;
card.setId(record.getCardId());
card.setBalance(balance);
//do databasechange
RecordDAO dao2 = new RecordDAO();
dao2.UpdateRecord(record,card);
result.setRecord(record);
result.setCard(card);
return result;
}
private static int calFee(String beginTime, String endTime) {
int fee = 0;
int beginYear = Integer.parseInt(beginTime.substring(0, 4));
int beginMonth = Integer.parseInt(beginTime.substring(5, 7));
int beginDay = Integer.parseInt(beginTime.substring(8,10));
int beginHour = Integer.parseInt(beginTime.substring(11, 13));
int beiginMinute = Integer.parseInt(beginTime.substring(14, 16));
int endYear = Integer.parseInt(endTime.substring(0, 4));
int endMonth = Integer.parseInt(endTime.substring(5, 7));
int endDay = Integer.parseInt(endTime.substring(8,10));
int endHour = Integer.parseInt(endTime.substring(11, 13));
int endMinute = Integer.parseInt(endTime.substring(14, 16));
int playMinutes = 0;
playMinutes = ((endYear - beginYear) *365 * 24
* 60
+ (endMonth - beginMonth) * 30 * 24
* 60 + (endDay - beginDay) * 24
* 60 + (endHour - beginHour) * 0
+ (endMinute - beiginMinute));
int modNum = playMinutes % 60;
int playHours = 0;
playHours = playMinutes /60;
if (playHours == 0 || (modNum >5 && playHours > 0)) {
playHours++;
}
fee = playHours * 2;
return fee;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -