Public class datapoke {
String pokeface; // String string pokepoint; // points String pokecolor; // color string pokeimgpath; // Poker picture correspondence address Boolean useflag = false; // Whether to use the tag false unused, TRUE use
public DataPoke () {} public void setuserFlag (boolean flag) {this.useFlag = flag;} public boolean getuserFlag () {return this.useFlag;} public String getPoint () {return this.pokepoint;} public String getColor () {Return this.PokeColor; PUBLIC STRING GETIMGPATH () {Return this.PokeImgpath;} public string getPokeface ()}
}
///
Import java.util. *;
Public class pokebean {private string [] color = {"black", "red", "flower", "sequa"}; private string pokeimgurl = "/ m / g / bj / images /" private linkedlist pokerist = new linkedList (); // poke list list DataPoke [] datapoke = new datapoke [52]; public pokebean () {} public void initPokelist () {for (int i = 0; i <= 51; i ) {datapoke [i] = New DataPoke (); // Initialization 52 DataPoke class variable storage} int over = 10; int count = 0; for (int i = 1; i <= 13; i ) {for (int J = 1; J < = 4; J ) {IF (i <10) DataPoke [count] .pokepoint = " i; // points 1-10 else datapoke [count] .Pokepoint =" over; // points 11-13 datapoke [count] .pokeface = "" i; // brand DataPoke [count] .pokecolor = color [j-1]; // Labo Colors 1-4: Black Red Mei Fang DataPoke [count] .PokeImgpath = PokeImgurl Integer.Tostring (i) "/" integer.tostring (j) ". PNG"; DataPoke [count] .SetUserflag (false); pokerist.add (count, datapoke [count); // will use internal Type DataPoke initializes 52 cards placed in LinkedList //system.out.println ("After Insert Poke -------- - = " count); count = count 1;}}} // After the initialization is completed, the shuffle // This function is not available here. PUBLIC VOID WashPoKelist () {int temp1 = 0; int TEMP2 = 0; LinkedList PokelistTemp = new LinkedList (); for (int i = 0; i // sequentially scrambled pokeData object insertion temp2 = temp1;} setuserLinklist (pokeListtemp);} public LinkedList getuserLinklist () {return this.pokeList;} public void setuserLinklist (LinkedList pokeListtemp) {this.pokeList = pokeListtemp;} public void Printback () {LinkedList Temp = getUserLinkList (); for (int i = 0; i / public class packageDb {private String userName; // user name private String userPswd; // password private long numuserguid; // user GUID private long numsex; // Gender private long numage; // Age private long nummoney; // User points private long numwincount; // user victory Board number private long numlostcount; // number of users fails Bureau public packageDb () {} // numwincount public long getNumwincount () {return this.numwincount;} public void setNumwincount (long numwincount) { this.numwincount = numwincount;} // numlostcount public long getNumlostcount () {return this.numlostcount;} public void setNumlostcount (long numlostcount) {this.numlostcount = numlostcount;} // numuserguid public long getNumuserguid () {return this.numuserguid ;} public void setNumuserguid (long numuserguid) {this.numuserguid = numuserguid;} /// numsex public long getNumsex () {return this.numsex;} public void setNumsex (long numsex) {this.numsex = numsex;} numage public Long getnumage () {returnimage;} public void setNumage (long numage) {this.numage = numage;} nummoney public long getNummoney () {return this.nummoney;} public void setNummoney (long nummoney) {this.nummoney = nummoney;} userName public String getUserName () {return this.userName;} public void setUserName (String userName) {this.userName = userName;} taken basic user information, need to setUserGuid () public void getUserInfo () throws Exception {String sql = "select * from uSER where NUMUSERGUID = ' " NumuserGuid " '"; try {dbob dbwork = new dbob (); dbwork.execute (sql); if (dbwork.result.next ()) {setusername (DBWork.Result.getstring (" vc2username "); SetNummoney ("Nummoney"); setNumage ("Numage"); setNumsex (DBWork.Result.getlong ("Numsex")); setNumlostcount (dbwork.result.getlong "NUMLOSTCOUNT"); setNumwinCount (DBWork.Result.getlong ("NumwinCount"));} DBWORK.RELEASERSOURCE ();} catch (exception e) {system.out.println ("getUserInfo Remove User Basic Information Error" E );}} / checks whether the new user registration name occupied public boolean checkUserInfo (String userNameNew) throws Exception {String sql = "select * from uSER where VC2USERNAME = '" userNameNew "'"; //System.out.println ( " ------------- Before-SQL: " SQL); Boolean Temp = true; try {dbob dbwork = new dbob (); dbwork.execute (sql); //system.out. Println ("------------ After-SQL:" SQL); if (dbwork.result.next ()) {temp = true;} else {temp = false;} dbwork. ReleaseResource ();} catch (exception e) {system.out.println ("CheckUserInfo Checks new user registration names" E);} return temp; // User name Was occupied, returns true, else return false;} / inserting a new user registration information public void insertUserNew (String userNamenew, String password, long sex, long age) throws Exception {String sql = "insert into USER (NUMUSERGUID, VC2USERNAME, VC2PASSWORD , Numsex, Numage) VALUES ("; SQL = SQL " Mobjseq.nextval, '"; SQL = SQL UserNameneW " ""; SQL = SQL Password ""; SQL = SQL SEX ","; SQL = SQL AGE ")") "; //system.out.println ("-------------BEFORE-SQL:" SQL); Try {dbob dbwork = new dbob (); dbwork.execute (sql); //system.out.println ("------------AFTER --SQL: " SQL); DBWORK. ReleaseResource ();} catch (exception e) {system.out.println ("InsertUsernew inserted new user registration information error" E);} / according to user name GUID public longuserguid (string un) throws Exception {STRING SQL = "SELECT NUMUSERGUID from user where vc2username = '" un "'"; // long Temp = 0; try {dbob dbwork = new dbob (); dbwork.execute (sql); if (dbwork.result.next) )) {TEMP = DBWORK.RESULT.GETLONG ("NumuserGuid");} dbwork.releaseeresource ();} catch (Exception E) {system.out.println ("getUserguid gets the user's Guid error" E); } Return Temp; / Check old user login public boolean checkUserOld (String userNameOld, String password) throws Exception {String sql = "select * from USER where VC2USERNAME = '" userNameOld "' and VC2PASSWORD = '" password "'"; boolean temp = true {DBOB DBWORK = New dbob (); dbwork.execute (sql); if (dbwork.result.next ()) {TEMP = true;} else {temp = false;} dbwork.releaseresource ();} catch Exception e) {system.out.println ("Checkuserold Check old users login" E);} return temp; // Old user's login user name and password correctly, return true, otherwise returning false;} / update user data public void updateUser (long userGuid, long userMoney, long winCount, long lostCount) throws Exception {String sql = "update USER set NUMMONEY =" userMoney ", NUMWINCOUNT =" winCount ", NUMLOSTCOUNT =" lostCount "where NUMUSERGUID =" UserGuid; try {dbob dbwork = new dbob (); dbwork.execute (sql); dbwork.releaseeresource ();} catch (exception e) {system.out.println ("UpdateUser update user data error" E); }}} /// import javax.servlet.http *;. import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import javax.servlet.jsp.PageContext; import java.util *.; // Random number needs to be used in import java.lang. *; public class gamePai {private HttpSession paiSession; private pokeBean userPokeBean; public gamePai () {} // get points user public int getPointuser (PageContext pagecontext) {HttpSession session = pagecontext.getSession (); LinkedList pokeLuser = (LinkedList) session.getAttribute ( "pokeuser"); int uservalue = 0; // user point calculation for (int i = 0; i INT TEMP = (int) (math.random () * 100)% 51; // Take the random number between 1-52 ((DataPoke). getUserflag ()) {TEMP = (INT) (Math.random () * 100)% 51;} poker.get (TEMP)); (DataPoke)); setUserflag (TRUE); Session.setttribute ("pokeuser", pokeruser); // Insert the user get the SESSION.SetAtttribute ("PoketotAl", PokelAll); // Update the total number} // Determine if the score of the computer is less than 16 points, less than 16 point, it returns true, need a computer to automatically add cards // there should call the jsp foliage public boolean judgeAddPc16 (pageContext pageContext) {HttpSession session = pageContext.getSession (); LinkedList pokeLpc = (LinkedList) session.getAttribute ( "pokepc" ); INT pcValue = 0; // User point calculation for (int i = 0; i Return False;} // Determine if the score of the computer is higher than 17 points, less than 21 points, return true, you need to automatically add the card // here should have JSP folio call PUBLIC Boolean JudgeadDPC21 (PageContext pageContext) {httpsession session = PageContext.getations (); LinkedList pokerpc = (linkedList) session.getattribute ("pokepc"); INT pcValue = 0; // User point calculation for (int i = 0; i // PC card to public void getNextPaipc (PageContext pageContext) {HttpSession session = pageContext.getSession (); LinkedList pokeLall = (LinkedList) session.getAttribute ( "poketotal"); LinkedList pokeLpc = (LinkedList) session.getAttribute ( "pokepc" ); int Temp = (int) (Math.random () * 100)% 51; // Take 1-52 Random WHILE ((Datapoke) PokelalAll.get (TEMP)). GetUserflag ()) { Temp = (int) (Math.random () * 100)% 51;} Pokelpc.add (PokeLall.get (TEMP)); (DataPoke) PokelalLlLlLlLlLLLLAG (TRUE); Session.SetaTRibute ("pokepc", pokerpc); // Insert the user get the SESSION.SetAttribute ("PoketotAl", PokelAll); // Update the Brand} // jsp foliar call determines whether the user bust, true, bust, bust jump to the foliage public boolean judgeBusrtuser (PageContext pageContext) {HttpSession session = pageContext.getSession () on the leaves; LinkedList pokeLuser = (LinkedList) session. GetAttribute ("pokeuser"); int usrvalue = 0; for (int i = 0; i // Get a list of the playing card user public ArrayList getPaiListUser (PageContext pageContext) {ArrayList templistuser = new ArrayList (); HttpSession session = pageContext.getSession (); LinkedList pokeLuser = (LinkedList) session.getAttribute ( "pokeuser"); for (int i = 0; i Integer.Parseint ((Datapoke) Pokeluser.get (i)). GetPoint ());} // computer point calculation for (int i = 0; i return 0;} public void initPai (PageContext pagecontext) {userPokeBean = new pokeBean (); paiSession = pagecontext.getSession (); // initialize to obtain session userPokeBean.initPokeList (); // initialize poker 52 LinkedList pokelistAll = userPokeBean.getuserLinklist ( ); LinkedList pokeristuser = new LinkedList (); linkedlist pokeristpc = new linkedList (); //userpokebean.washpokeList();// Initialization After the poker, there is a problem, you can't shift Paisessional.setttribute ("PoketotAl", Pokelistall; // Place the initialized and wash Poker in the player session ("pokeuser", pokeristuse; // Initialize User Poker Data Paisession.SetaTRibute ("pokepc", pokeristpc); // Initialize computer poker data / /userpokebean.printback();// play card to see} // Big Print comes to detect public void printpai () {UserPokeBean.printback ();} // Take 52 poker cards every time you re-open flag is set to false, unused public void resetPai (pageContext pagecontext) {HttpSession session = pagecontext.getSession (); LinkedList pokeList = (LinkedList) session.getAttribute ( "poketotal"); for (int i = 0; i ); // give players // for (int i = 0; i <2; i ) {// take 2 cards from the middle to player // IntTemp1 = (int) (Math.random () * 100) % 51; // Take 1-52 Random // INTTEMP2 = (INT) (INT) (INTTEMP1 == INTTEMP2) {INTTEMP1 = (int) (Math.random () * 100)% 51; // Take the random number INTTEMP2 = (int) between 1-52 (math.random () * 100)% 51;} pokeristTempuser.Add (PokelistTempall1.Get (INTTEMP1)); PokelistTempuser .add (PokelistTemPall1.get (datapoke)); (INTTEMP1)). setUserflag (true); (DataPoke) PokelistTemPall1.get (INTTEMP2)). setUserflag (True); // while ("(datapoke) pokeristtempall1.get (intTEMP1)). getUserflag ())) // If a duplicate random number or the card has been taken, re-extTTEMP1 = (intTEMP1 = (intTEMP1 = (Math.random () * 100)% 51; //pokelistTempuser.Add (PokeListTempall1.Get (ITTEMP1)); //system.out.println ("Address to the player's address: ((datapoke) PokelistTempall1 .get (intTEMP1)). GetImgpath ()); //system.out.println ("The number of cards for the player's card:" ((DataPoke) PokelistTemPall1.get (intTemp1)). getPokeface ()); / /System.out.println ("************************************************** ************ "); //pokelistTempuser.a // The card will be taken to use status // (4DATAPOKE)PokelistTemPall1.get(intTemp1 )).setUserflag (true); // intTEMP2 = INTTEMP1; //} session.setttribute ("pokeuser", pokeristTempuser); // Insert the user's get to the user's session in Session.setttribute ("PoketotAl", PokelistTemPall1); // Update the total card // Take 2 sheets from the rear card to the computer // int INTTEMP3 = 0; // int INTTEMP4 = 0; // Remove the total card out // LinkedList PokelistTemPall2 = (LinkedList) session.getattribute ("Poketotal" ); // for (int i = 0; i <2; i ) {// Take 2 cards from the Total Brand to PC // INTTEMP3 = (int) (Math.random () * 100) % 51; // Take 1-52 Random 1 // While (INTTEMP4 == INTTEMP3 && ((DataPoke) PokelistTempall2.Get (intTemp3)). GetUserflag ())) // If there is a repeated random number Or the card has been taken, re-extort / INTTEMP3 = (int) (math.random () * 100)% 51; // pokeristTemppc.Add (I, pokeristTempall2.get (intTemp3)); // will be taken The card is set to use // ((Datapoke) PokelistTemPall2.get (intTEMP3)). SetUserflag (true); // INTTEMP4 = INTTEMP3; //} //session.setttribute ("Pokepc" ,ropelistTemPPC );// Insert Computer Get the card to the user's session //session.setttribute ("PoketotAl ", the hostTemPall2; // update the total Try {thread.sleep (30);} catch (exception ex) {EX.PrintStackTrace ();}} Public void getfirstPAIPC (PageContext PageContext) {httpsession session = pageContext.getations (); // linkedlist pokeristtempuser = new linkedList (); LinkedList pokeristTemppc = (LinkedList) session.gettribute ("pokepc"); pokeristTemppc.clear (); first from 52 points volumes to randomly draw 4, two of the players, two // int INTTEMP1 = 0; // int INTTEMP2 = 0; // First remove the total volume // paises // linkedList pokeristTemPall1 = (LinkedList) session.getattribute ("PoketotAl"); // Give the player // for (int i = 0; I <2; i ) {// take 2 cards from the middle to the player // IntTemp1 = (int) (Math.random () * 100)% 51 ; // Take the random number 1 // while (INTTEMP2 == INTTEMP1 && ((datapoke)). GetUserflag ())) // If a repeated random number or The card has been taken and // intTEMP1 = (int) (math.random () * 100)% 51; // pokeristTempuser.Add (i, pokeristTempall1.get (intTemp1)); // will be taken For use status // ((datapoke) PokelistTemPall1.get (intTEMP1)). SetUserflag (true); // intTEMP2 = INTTEMP1; //} //session.setttribute ("Pokeuser" ,ropelistTempuser) ;/ inserted user get Brand to the user's session //session.setttribute ("PoketotAl ", update the total card // to remove the total volume to the TinkedList PokelistTemPall = (LinkedList) session.getattribute (" poketotAl "); int INTTEMP1 = 0 ; Int INTTEMP2 = 0; while (intTEMP1 == INTTEMP2 || ((datapoke) pokeristtempall.get (intTEMP1)). GetUserflag () == true || ((datapoke) pokeristTemPall.get (intTemp2)). GetUserflag () = = true) {INTTEMP1 = (int) (Math.random () * 100)% 51;} () * 100)% 51;} * 100)% 51; // PokelistTemp PC.add (pokeListtempall.get (inttemp1)); pokeListtempPC.add (pokeListtempall.get (inttemp2));. ((DataPoke) pokeListtempall.get (inttemp1)) setuserFlag (true); ((DataPoke) pokeListtempall.get (inttemp2 ))). setUserflag (true); // Take 2 to the computer from the rear brand // for (int i = 0; i <2; i ) {// Take 2 cards from the Total Brand to PC // IntTemp3 = (int) (math.random () * 100)% 51 ; // Take the random number 1 // while (INTTEMP4 == INTTEMP3 && ((datapoke)). GetUserflag ()) == True) // If repeated random Number or this card has been taken, re-extort / INTTEMP3 = (int) (math.random () * 100)% 51; // pokeristTemppc.add (PokelistTempall2.Get (INTTEMP3)); // system.out.println ("Address to the card of the computer:" ((Datapoke) pokeristtempall2.get (intTemp3)). GetImgpath ()); // system.out.println ("Give computer card number:" ( DataPoke) PokelistTemPall2.get (intTEMP3)). GetPokeface ()); // The card will be taken to use status // ((DataPoke) PokelistTemPall2.Get (intTemp3)). SetUserflag (true); // intTEMP4 = IntTemp3 ; //} session.setttribute ("pokepc", pokeristTemppc); // Insert the computer get the card to the user's session ("PoketotAl", pokeristtempall; // Update the Trise Try {thread.sleep (30 (} Catch (exception ex) {ex.printstacktrace (); } }