Source Code Cross Referenced for Magic8Ball.java in  » EJB-Server-resin-3.1.5 » examples » example » 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 » EJB Server resin 3.1.5 » examples » example 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package example;
002:
003:        import com.caucho.util.L10N;
004:        import java.util.logging.Logger;
005:        import java.util.logging.Level;
006:
007:        import java.util.Random;
008:        import java.util.HashMap;
009:
010:        /**
011:         * Professor Trelawney's magic 8 ball.
012:         * The magic 8 ball will return a prophecy with getProphecy().
013:         *
014:         * <p>The default prophet is Professor Trelawney (of course).   If you wish to
015:         * change the prophet that provides the answer, use
016:         * setProphet(name), where name is one of "trelawney", "classic", or "kingwu".  
017:         */
018:        public class Magic8Ball {
019:            static protected final Logger log = Logger
020:                    .getLogger(Magic8Ball.class.getName());
021:            static final L10N L = new L10N(Magic8Ball.class);
022:
023:            private final static String DEFAULT_PROPHET = "trelawney";
024:
025:            private Random _random = new Random();
026:
027:            private String _prophet = DEFAULT_PROPHET;
028:
029:            private HashMap _prophets = new HashMap();
030:
031:            public Magic8Ball() {
032:                _prophets.put("trelawney", new String[] {
033:                        "The future for you is very dire",
034:                        "Within a fortnight you will surely die",
035:                        "Grave trouble awaits you",
036:                        "You must not leave the room",
037:                        "The stars are aligned for grave injury", });
038:                _prophets.put("classic",
039:                        new String[] {
040:
041:                        "Signs point to yes", "Yes", "Reply hazy, try again",
042:                                "Without a doubt", "My sources say no",
043:                                "As I see it, yes", "You may rely on it",
044:                                "Concentrate and ask again",
045:                                "Outlook not so good", "It is decidedly so",
046:                                "Better not tell you now", "Very doubtful",
047:                                "Yes - definitely", "It is certain",
048:                                "Cannot predict now", "Most likely",
049:                                "Ask again later", "My reply is no",
050:                                "Outlook good", "Don't count on it", });
051:                _prophets
052:                        .put(
053:                                "kingwu",
054:                                new String[] {
055:                                        "THE CREATIVE works sublime success, Furthering through perseverance.",
056:                                        "THE RECEPTIVE brings about sublime success, Furthering through the perseverance of a mare.  If the superior man undertakes something and tries to lead, He goes astray; But if he follows, he finds guidance.  It is favorable to find friends in the west and south, To forego friends in the east and north.  Quiet perseverance brings good fortune.",
057:                                        "DIFFICULTY AT THE BEGINNING works supreme success, Furthering through perseverance.  Nothing should be undertaken.  It furthers one to appoint helpers.",
058:                                        "YOUTHFUL FOLLY has success.  It is not I who seek the young fool; The young fool seeks me.  At the first oracle I inform him.  If he asks two or three times, it is importunity.  If he importunes, I give him no information.  Perseverance furthers.",
059:                                        "WAITING. If you are sincere, You have light and success.  Perseverance brings good fortune.  It furthers one to cross the great water.",
060:                                        "CONFLICT. You are sincere And are being obstructed.  A cautious halt halfway brings good fortune.  Going through to the end brings misfortune.  It furthers one to see the great man.  It does not further one to cross the great water.",
061:                                        "THE ARMY. The army needs perseverance And a strong man.  Good fortune without blame.",
062:                                        "HOLDING TOGETHER brings good fortune.  Inquire of the oracle once again Whether you possess sublimity, constancy, and perseverance; Then there is no blame.  Those who are uncertain gradually join.  Whoever come too late Meets with misfortune.",
063:                                        "THE TAMING POWER OF THE SMALL Has success.  Dense clouds, no rain from our western region.  ",
064:                                        "TREADING. Treading upon the tail of the tiger.  It does not bite the man. Success.",
065:                                        "PEACE. The small departs, The great approaches.  Good fortune. Success.",
066:                                        "STANDSTILL. Evil people do not further The perseverance of the superior man.  The great departs; the small approaches.",
067:                                        "FELLOWSHIP WITH MEN in the open.  Success.  It furthers one to cross the great water.  The perseverance of the superior man furthers.",
068:                                        "POSSESSION IN GREAT MEASURE.  Supreme success.",
069:                                        "MODESTY creates success.  The superior man carries things through.",
070:                                        "ENTHUSIASM. It furthers one to install helpers And to set armies marching.",
071:                                        "FOLLOWING has supreme success.  Perseverance furthers. No blame.",
072:                                        "WORK ON WHAT HAS BEEN SPOILED Has supreme success.  It furthers one to cross the great water.  Before the starting point, three days.  After the starting point, three days.",
073:                                        "APPROACH has supreme success.  Perseverance furthers.  When the eighth month comes, There will be misfortune.",
074:                                        "CONTEMPLATION. The ablution has been made, But not yet the offering.  Full of trust they look up to him.",
075:                                        "BITING THROUGH has success.  It is favorable to let justice be administered.",
076:                                        "GRACE has success.  In small matters It is favorable to undertake something.",
077:                                        "SPLITTING APART. IT does not further one To go anywhere.",
078:                                        "RETURN. Success.  Going out and coming in without error.  Friends come without blame.  To and fro goes the way.  On the seventh day comes return.  It furthers one to have somewhere to go.",
079:                                        "INNOCENCE. Supreme success.  Perseverance furthers.  If someone is not as he should be, He has misfortune, And it does not further him To undertake anything.",
080:                                        "THE TAMING POWER OF THE GREAT.  Perseverance furthers.  Not eating at home brings good fortune.  It furthers one to cross the great water.",
081:                                        "THE CORNERS OF THE MOUTH.  Perseverance brings good fortune.  Pay heed to the providing of nourishment And to what a man seeks To fill his own mouth with.",
082:                                        "PREPONDERANCE OF THE GREAT.  The ridgepole sags to the breaking point.  It furthers one to have somewhere to go.  Success.",
083:                                        "The Abysmal repeated.  If you are sincere, you have success in your heart, And whatever you do succeeds.",
084:                                        "THE CLINGING. Perseverance furthers.  It brings success.  Care of the cow brings good fortune.",
085:                                        "Influence. Success.  Perseverance furthers.  To take a maiden to wife brings good fortune.",
086:                                        "DURATION. Success. No blame.  Perseverance furthers.  It furthers one to have somewhere to go.",
087:                                        "RETREAT. Success.  In what is small, perseverance furthers.",
088:                                        "THE POWER OF THE GREAT. Perseverance furthers.  ",
089:                                        "PROGRESS. The powerful prince Is honored with horses in large numbers.  In a single day he is granted audience three times.",
090:                                        "DARKENING OF THE LIGHT. In adversity It furthers one to be persevering.",
091:                                        "THE FAMILY. The perseverance of the woman furthers.  ",
092:                                        "OPPOSITION. In small matters, good fortune.",
093:                                        "OBSTRUCTION. The southwest furthers.  The northeast does not further.  It furthers one to see the great man.  Perseverance brings good fortune.",
094:                                        "DELIVERANCE. The southwest furthers.  If there is no longer anything where one has to go, Return brings good fortune.  If there is still something where one has to go, Hastening brings good fortune.",
095:                                        "DECREASE combined with sincerity Brings about supreme good fortune Without blame.  One may be persevering in this.  It furthers one to undertake something.  How is this to be carried out?  One may use two small bowls for the sacrifice.",
096:                                        "INCREASE. It furthers one To undertake something.  It furthers one to cross the great water.",
097:                                        "BREAK-THROUGH. One must resolutely make the matter known At the court of the king.  It must be announced truthfully. Danger.  It is necessary to notify one's own city.  It does not further to resort to arms.  It furthers one to undertake something.",
098:                                        "COMING TO MEET. The maiden is powerful.  One should not marry such a maiden.",
099:                                        "GATHERING TOGETHER. Success.  The king approaches his temple.  It furthers one to see the great man.  This brings success. Perseverance furthers.  To bring great offerings creates good fortune.  It furthers one to undertake something.",
100:                                        "PUSHING UPWARD has supreme success.  One must see the great man.  Fear not.  Departure toward the south Brings good fortune.",
101:                                        "OPPRESSION. Success. Perseverance.  The great man brings about good fortune.  No blame.  When one has something to say, It is not believed.",
102:                                        "THE WELL. The town may be changed, But the well cannot be changed.  It neither decreases nor increases.  They come and go and draw from the well.  If one gets down almost to the water And the rope does not go all the way, Or the jug breaks, it brings misfortune.",
103:                                        "REVOLUTION. On your own day You are believed.  Supreme success, Furthering through perseverance.  Remorse disappears.",
104:                                        "THE CALDRON. Supreme good fortune.  Success.",
105:                                        "SHOCK brings success.  Shock comes-oh, oh!  Laughing words -ha, ha!  The shock terrifies for a hundred miles, And he does not let fall the sacrificial spoon and chalice.",
106:                                        "KEEPING STILL. Keeping his back still So that he no longer feels his body.  He goes into his courtyard And does not see his people.  No blame.",
107:                                        "DEVELOPMENT. The maiden Is given in marriage.  Good fortune.  Perseverance furthers.",
108:                                        "THE MARRYING MAIDEN.  Undertakings bring misfortune.  Nothing that would further.",
109:                                        "ABUNDANCE has success.  The king attains abundance.  Be not sad.  Be like the sun at midday.",
110:                                        "THE WANDERER. Success through smallness.  Perseverance brings good fortune To the wanderer.",
111:                                        "THE GENTLE. Success through what is small.  It furthers one to have somewhere to go.  It furthers one to see the great man.",
112:                                        "THE JOYOUS. Success.  Perseverance is favorable.",
113:                                        "DISPERSION. Success.  The king approaches his temple.  It furthers one to cross the great water.  Perseverance furthers.",
114:                                        "LIMITATION. Success.  Galling limitation must not be persevered in.",
115:                                        "INNER TRUTH. Pigs and fishes.  Good fortune.  It furthers one to cross the great water.  Perseverance furthers.",
116:                                        "PREPONDERANCE OF THE SMALL. Success.  Perseverance furthers.  Small things may be done; great things should not be done.  The flying bird brings the message: It is not well to strive upward, It is well to remain below.  Great good fortune.",
117:                                        "AFTER COMPLETION. Success in small matters.  Perseverance furthers.  At the beginning good fortune.  At the end disorder.",
118:                                        "BEFORE COMPLETION. Success.  But if the little fox, after nearly completing the crossing, Gets his tail in the water, There is nothing that would further.", });
119:            }
120:
121:            /**
122:             * Set the prophet to use.
123:             */
124:            public void setProphet(String prophet) {
125:                if (prophet == null)
126:                    _prophet = DEFAULT_PROPHET;
127:                else
128:                    _prophet = prophet;
129:            }
130:
131:            /**
132:             * Get the prophet that will be used.
133:             */
134:            public String getProphet() {
135:                return _prophet;
136:            }
137:
138:            /**
139:             * Get a prophecy.
140:             */
141:            public String getProphecy() {
142:                String[] prophecies = (String[]) _prophets.get(_prophet);
143:
144:                if (prophecies == null) {
145:                    return "a false prophet is never wise";
146:                } else {
147:                    int i = _random.nextInt(prophecies.length);
148:                    return prophecies[i];
149:                }
150:            }
151:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.