?? user.java
字號:
package com.dfun.blackjackServer;
import java.sql.*;
/**************************************************
* @author Beetle
* 類功能介紹:用戶對象由主控生成,當連接二初始化完畢時通知主控
* 由主控生成一個新的用戶對象當斷線或用戶退出時由主控刪除該用戶
* 該對象進行用戶操作
**************************************************/
public class User {
public String userId; //用戶id
public int userState; //用戶狀態(tài) 10為觀眾
public String houseId;
private Control ctrl; //主控
private UserManage userManage; //用戶管理
public String phoneNumber; //電話號碼
public String password; //密碼
public String userName; //用戶名
public long chipIn; //已下的注
private Statement stm;
public boolean isDouble;//是否雙倍下注
public boolean isSpread; //是否分牌
public User(Control ctrl, UserManage userManage, String userId,String phoneNumber,String password, String userName) {
this.ctrl = ctrl;
this.userManage = userManage;
this.userId = userId;
this.phoneNumber = phoneNumber;
this.password=password;
this.userName = userName;
chipIn = 0; //用戶所下的注
houseId = "";
userState = 0;
isDouble=false;
isSpread=false;
}
/*****************************************************
* 功能介紹:向用戶輸出用戶總分
* 輸入?yún)?shù):無
* 輸出參數(shù):無
****************************************************/
public long getJetton() {
long jetton;
ResultSet rs;
try {
// rs=ctrl.dataConn.getRs("select * from user where phonenumber='" + phoneNumber + "'");
//if (rs.next()) {
// return rs.getInt("jetton");
//}
// else {
return 1000;
// }
}
catch (Exception e) {
System.out.println("取得籌碼錯誤"+e.getMessage());
return 0;
}
}
/*****************************************************
* 功能介紹:設置籌碼
* 輸入?yún)?shù):無
* 輸出參數(shù):無
****************************************************/
public void setJetton(long Jetton) {
try {
//ctrl.dataConn.setData("update User set Jetton=" + Jetton +" where phoneNumber='" + phoneNumber + "'");
}
catch (Exception e) {
System.out.println("設置籌碼錯誤"+e.getMessage());
}
}
/*****************************************************
* 功能介紹:取得用戶所下的注
* 輸入?yún)?shù):無
* 輸出參數(shù):無
****************************************************/
public long getChinIn() {
return chipIn;
}
/*****************************************************
* 功能介紹:用戶下注
* 輸入?yún)?shù):籌碼
* 輸出參數(shù):無
****************************************************/
public void setChipIn(long num) {
chipIn = num;
if(chipIn==0){
userState=10;//如果用戶下了零注則成為觀眾
}else{
setJetton(getJetton() - chipIn);
userState = 1; //將用戶狀態(tài)標志為已下注完畢
}
House house = (House) ctrl.houseManage.houseList.get(houseId);
house.chuckChipOver(); //檢測是否所有用戶都下注完畢,如果完畢則發(fā)牌
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -