Source Code Cross Referenced for GameManagerImpl.java in  » J2EE » Enhydra-Demos » poker » business » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » Enhydra Demos » poker.business 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package poker.business;
002:
003:        import java.util.Vector;
004:        import java.sql.SQLException;
005:        import poker.data.user.*;
006:        import poker.data.game.*;
007:        import poker.business.GameList;
008:        import poker.spec.*;
009:
010:        /**
011:         *
012:         * EnhyDraw!, beta 4, 5/21/99
013:         *
014:         * Copyright 1999, Larry Wolcot & Daryl Tempesta
015:         * ALL rights reserved. Not for commercial use
016:         * without written permission from both authors.
017:         *
018:         * This class is a basic wrapper for the BDO's (like GameList)
019:         * It manages all of the active cardGames, PitBoss Statistics, etc.
020:         */
021:        public class GameManagerImpl implements  GameManager,
022:                java.io.Serializable {
023:
024:            private PokerGame game;
025:            private GameList gameList = new GameList(0);
026:            private PitBossListImpl pitBossList = new PitBossListImpl();
027:            private String appName = "Poker";
028:
029:            /**
030:             * Set the useDB flag in the GameList object. If useDB is false,
031:             * the GameList object will use a standard Vector (in memory)
032:             * to hold all of the active PokerGame objects. if useDB is set to
033:             * true, it will mirror the Vector's elements into the database.
034:             */
035:            public void setUseDB(boolean useDB) throws Exception {
036:                try {
037:                    gameList.setUseDB(useDB);
038:                    //PitBoss persistance is not finished
039:                    pitBossList.setUseDB(useDB);
040:                } catch (Exception e) {
041:                    throw e;
042:                }
043:            }
044:
045:            /**
046:             * Total number of players sent to the poor house!
047:             */
048:            public String getTotalBankrupt() {
049:                //String ret = new Integer(totalBankrupt).toString();
050:                //return ret;
051:                int total = 0;
052:                total = pitBossList.getPitBossVDO(appName).getTotalBankrupt();
053:                return new Integer(total).toString();
054:            }
055:
056:            /**
057:             * Total dollars the house has won/lost
058:             */
059:            public String getHouseProfit() {
060:                int total = 0;
061:                total = pitBossList.getPitBossVDO(appName).getTotalDollars();
062:                return new Integer(total).toString();
063:            }
064:
065:            /**
066:             * Check the active gameList and return total number of players
067:             */
068:            public String getTotalPlayers() {
069:                String ret = new Integer(gameList.getCount()).toString();
070:                return ret;
071:            }
072:
073:            /**
074:             * Total number hands dealt
075:             */
076:            public String getTotalHandsDealt() {
077:                int total = 0;
078:                total = pitBossList.getPitBossVDO(appName).getTotalHandsDealt();
079:                return new Integer(total).toString();
080:            }
081:
082:            /**
083:             * Total number of hands won by all players
084:             */
085:            public String getTotalHandsWon() {
086:                int total = 0;
087:                total = pitBossList.getPitBossVDO(appName).getTotalHandsWon();
088:                return new Integer(total).toString();
089:            }
090:
091:            /**
092:             * Total number of hands lost by all players
093:             */
094:            public String getTotalHandsLost() {
095:                int totalWon = 0;
096:                int totalPlayed = 0;
097:                totalWon = pitBossList.getPitBossVDO(appName)
098:                        .getTotalHandsWon();
099:                totalPlayed = pitBossList.getPitBossVDO(appName)
100:                        .getTotalHandsDealt();
101:                return new Integer(totalPlayed - totalWon).toString();
102:            }
103:
104:            /**
105:             * Incriment totalHandsWon by n
106:             */
107:            public synchronized void setTotalHandsWon(int n) {
108:                synchronized (pitBossList) {
109:                    n = n
110:                            + pitBossList.getPitBossVDO(appName)
111:                                    .getTotalHandsWon();
112:                    pitBossList.getPitBossVDO(appName).setTotalHandsWon(n);
113:                }
114:            }
115:
116:            /**
117:             * Incriment totalBankrupt by n
118:             */
119:            public synchronized void setTotalBankrupt(int n) {
120:                synchronized (pitBossList) {
121:                    n = n
122:                            + pitBossList.getPitBossVDO(appName)
123:                                    .getTotalBankrupt();
124:                    pitBossList.getPitBossVDO(appName).setTotalBankrupt(n);
125:                }
126:            }
127:
128:            /**
129:             * Incriment totalHandsDealt by n
130:             */
131:            public synchronized void setHandsDealt(int n) {
132:                synchronized (pitBossList) {
133:                    n = n
134:                            + pitBossList.getPitBossVDO(appName)
135:                                    .getTotalHandsDealt();
136:                    pitBossList.getPitBossVDO(appName).setTotalHandsDealt(n);
137:                }
138:            }
139:
140:            /**
141:             * Incriment totalDollars (won) by n
142:             */
143:            public synchronized void setDollars(int n) {
144:                synchronized (pitBossList) {
145:                    n = n
146:                            + pitBossList.getPitBossVDO(appName)
147:                                    .getTotalDollars();
148:                    pitBossList.getPitBossVDO(appName).setTotalDollars(n);
149:                }
150:            }
151:
152:            /**
153:             * same as setDollars
154:             */
155:            public synchronized void setTotalDollars(int n) {
156:                setDollars(n);
157:            }
158:
159:            /**
160:             * Return a (COPY)list of active games
161:             */
162:            public synchronized Vector getGameList() {
163:                GameList gameListCopy = this .gameList.getCopy();
164:                return gameListCopy;
165:            }
166:
167:            /**
168:             * Return the size() of gameList
169:             */
170:            public synchronized int getCount() {
171:                return gameList.getCount();
172:            }
173:
174:            /**
175:             * return the top ten players ranked by cash won
176:             */
177:            public synchronized Vector getTopTen() {
178:                Vector topTen = null;
179:
180:                topTen = gameList.getTopTen();
181:
182:                return topTen;
183:
184:            }
185:
186:            /**
187:             * Check to see if this name has been used
188:             */
189:            public synchronized boolean getIsNameUsed(String name) {
190:                boolean isUsed = false;
191:
192:                if (gameList.getIsNameUsed(name)) {
193:                    isUsed = true;
194:                }
195:
196:                return isUsed;
197:            }
198:
199:            /**
200:             * Authenticate user against gameList object
201:             */
202:            public synchronized boolean authenticate(String name, String pw) {
203:                boolean isAuth = false;
204:
205:                if (gameList.authenticate(name, pw)) {
206:                    isAuth = true;
207:                }
208:                return isAuth;
209:            }
210:
211:            /**
212:             * Return the game that belongs to user name String
213:             */
214:            public synchronized PokerGame getGame(String name) {
215:                PokerGame this Game = null;
216:
217:                this Game = gameList.getGame(name);
218:
219:                return this Game;
220:            }
221:
222:            /**
223:             * Add a game to the gameList
224:             */
225:            public synchronized void addGame(PokerGame newGame) {
226:                //lock gameList object for TOTAL threadsave opps
227:                //This is OK for less intense apps like this one,
228:                //but not the best way to go for high transaction
229:                //DB volumes
230:                synchronized (gameList) {
231:                    gameList.addGame(newGame);
232:                }
233:            }
234:
235:            /**
236:             * get rank of current dollars compared to the gameList
237:             */
238:            public synchronized int getRank(int cash) {
239:                int rank = gameList.getRank(cash);
240:                return rank;
241:            }
242:
243:            /**
244:             * remove thisGame from the gameList
245:             */
246:            public synchronized void removeGame(String name) {
247:                gameList.removeGame(name);
248:            }
249:
250:            /**
251:             * Make sure the DB gets updated if this is a DODS object
252:             */
253:            public synchronized void updateGame(PokerGame thisGame) {
254:                gameList.updateGame(thisGame);
255:            }
256:
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.