Free Essay

Hangman Game

In:

Submitted By jamie271095
Words 593
Pages 3
import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.util.Random;

class Hangmangame extends Applet implements ActionListener{

static final int DEAD=13; // amount of errors till loss private int errors; // amount of errors private String message; // error or victorie private String information; // information of the message private String rword; // the rword private StringBuffer gword;// the gword private Button bStart; // Button "Restart" private Button bGo; // Button "Go" private TextField tfLetter; // letter box private Font fnt; // common font

public void init(){ fnt = new Font( "Monospaced", 0, 12 ); // Create textbox for guess letter tfLetter = new TextField(); // Create buttons and labels bStart = new Button("Restart"); bGo = new Button("Go"); // Add the graphical elements to the applet add(bStart); add(new Label("Guess a letter:")); add(tfLetter); add(bGo); // Buttons are events: bStart.addActionListener(this); bGo.addActionListener(this); // Start first game initGame(); } public void initGame(){ /* Setting the errors to 0 */ errors=0;

/* Enter the wordslist, separated by a | here: */ String str = "computer|radio|calculator|teacher|bureau|police|geometry|president|subject|country|enviroment|classroom|animals|province|month|politics|puzzle|instrument|kitchen|language|vampire|ghost|solution|service|software|virus25|security|phonenumber|expert|website|agreement|support|compatibility|advanced|search|triathlon|immediately|encyclopedia|endurance|distance|nature|history|organization|international|championship|government|popularity|thousand|feature|wetsuit|fitness|legendary|variation|equal|approximately|segment|priority|physics|branche|science|mathematics|lightning|dispersion|accelerator|detector|terminology|design|operation|foundation|application|prediction|reference|measurement|concept|perspective|overview|position|airplane|symmetry|dimension|toxic|algebra|illustration|classic|verification|citation|unusual|resource|analysis|license|comedy|screenplay|production|release|emphasis|director|trademark|vehicle|aircraft|experiment"; String[] temp; /* delimiter */ String delimiter = "\\|"; /* given string will be split by the argument delimiter provided. */ temp = str.split(delimiter); /* Setting the seed */ Random randomGenerator = new Random(); /* Generating random number */ int randomInt = randomGenerator.nextInt(temp.length); rword = temp[randomInt]; char positions[] = new char[rword.length()]; for (int i=0; i 0){ // ground g.drawLine(90, baseY,200,baseY); } if (errors > 1){ // bar up g.drawLine(125,baseY,125,baseY-100); } if (errors > 2){ g.drawLine(110,baseY,125,baseY-15); } if (errors > 3){ g.drawLine(140,baseY,125,baseY-15); } if (errors > 4){ // side bar g.drawLine(125,baseY-100,175,baseY-100); } if (errors > 5){ g.drawLine(125,baseY-85,140,baseY-100); } if (errors > 6){ // rope g.drawLine(175,baseY-100,175,baseY-75); } if (errors > 7){ // body g.drawOval(170,baseY-75,10,12); } if (errors > 8){ g.drawOval(170,baseY-65,15,25); } if (errors > 9){ // arms g.drawLine(160,baseY-65,170,baseY-60); } if (errors > 10){ g.drawLine(183,baseY-60,193,baseY-65); } if (errors > 11){ // legs g.drawLine(165,baseY-30,170,baseY-45); } if (errors > 12){ g.drawLine(183,baseY-45,193,baseY-30); } // Show the messages g.drawString( message, 40, baseY+25 ); g.drawString( information, 25, baseY+45 ); g.drawString( new String (gword), 110, 60); } public void actionPerformed(ActionEvent e){ if (e.getSource() == bStart){ initGame(); } if (e.getSource() == bGo){ processTurn(); // Delete the letter input box tfLetter.setText(""); repaint(); } } private void processTurn(){ String s, t; char a; s = tfLetter.getText(); a = s.charAt(0); if (!Character.isLetter(a)){ message="Only enter letters!"; return; } if (s.length()>1){ message="One letter at a time!"; return; } // Has the letter been guessed t = new String(gword); if (t.contains(s)){ message="Letter has already been guessed"; return; } // If the letter doesn't occur in the rword if (!rword.contains(s)){ message=""; errors++; if (errors==DEAD){ message="You lost!"; information = "Click on restart for another chance!"; } return; } // Replace dots in gword with the found letter. for (int i=0; i

Similar Documents

Free Essay

Ghmgj

...PCSX2 1.0.0 Frequently Asked Questions Section I: General questions about the project What is the aim of this project? The aim of this project is to emulate the PlayStation 2, allowing people to play their PS2 games on a pc. This requires having an original PlayStation 2 console (for the BIOS) and of course having the original games as well. Is the project open source? Yes, the project is open source, and it is licensed under the GNU General Public License v3. Can I help the project? Sure you can, please refer to this thread HERE. Is the release package complete? Can I play out of the box? No, the release package is not complete. You need to do at least 2 things before you can play: • • • First, you need to put in your own BIOS. Dump your PlayStation 2 BIOS from your own console. The BIOS dumper is HERE. Second, you need to configure the plugins in the emulator. You can use the official guide found HERE. (Optional) Third, you may need to update your DirectX in order for GSdx to work. GSdx is our suggested graphics plugin. Update DirectX with the web installer HERE. Section II: General questions about the emulator What are the requirements for using this emulator? Minimum • • • • Windows/Linux OS CPU that supports SSE2 (Pentium 4 and up, Athlon64 and up) GPU that supports Pixel Shaders 2.0 512MB RAM Recommended • • • • Windows Vista/7 (both 32bit and 64bit supported) CPU: Core 2 Duo, Core i3/5/7, Phenom II (all at 3.4Ghz+) GPU: 8800GT or...

Words: 1152 - Pages: 5

Premium Essay

Football

...Football, to me, is more than just a game. I have probably learned more valuable lessons from it than from school. When I joined the team freshman year, I didn’t realize what I was getting into. Even though I had been playing since fourth grade and knew it was hard work, nothing would prepare me for the effort I would put into football that year. We worked all summer in the weight room and ran on the track to get in physical and mental shape before the season. See, football is more of a mental sport than anything else, so running on the track wasn’t only about getting in shape. We would push our minds by running as hard as we could even if we felt like we were going to pass out. At the beginning, I was immature and only thought of myself, sometimes even giving up when I was tired or hurting. Then after the third game I had a season-ending injury. Imagine working all summer and then only being able to play three games! I needed surgery on my arm and at least five months to recover. Needless to say, I was sidelined for the rest of the season, but this actually helped me realize that since you never know when your last play will be, you should try your hardest in football and life. After freshman year I decided that I would always give my best effort. Playing varsity football has taught me so much more than just what my assignments are on a particular play or how to block. I have learned to think about others first, and realized how important working hard is...

Words: 435 - Pages: 2

Premium Essay

Soap Football Feasibility Study

...Feasibility Study for Soap Football Business Venture By: Kunal Sharma 3077704 November 2012 88/100 – well done and a viable concept. ~Steve Dhillon Table of Contents Page # 1. Cover Page 1 2. Table of contents 2 3. The concept 3 4. Preliminary marketing planning 5 5. Customers 6 6. Competition 7 7. Location 8 8. Pricing strategy 9 9....

Words: 2256 - Pages: 10

Free Essay

Paper on "The Natural"

...sports movies that I have ever seen. Matter of a fact it is one of the most inspiring movies that I have ever seen altogether. It is about a baseball player named Roy Hobbs, whose main goal in the movie is to become the best baseball player to ever play the game. It starts out with Roy throwing with his dad at their farm when Roy was a young kid. Then it jumps to a scene where it shows Roy’s dad dying of a heart attack under the tree that is in their front yard. Then it has Roy standing in front of his window one night just looking at the tree when a streak of lightening came down and struck the tree splitting it into two pieces. Now Roy took part of the tree and made a bat out of it and called it Wonderboy. Then it jumps to where Roy is at the age of just getting out of high school and it shows him talking to his girlfriend at the time, whose name was Iris. He was telling her that he had talked to a team out of Chicago and that he had a tryout with the team. As the movie goes a long, it shows him getting on a train with his agent, or the guy that found him and got his tryout, but also on the train it has a guy named Whammer on the train that is supposed to be the best baseball player that was ever going to play the game of baseball. So they stop at a carnival to enjoy their time and during this time Roy’s man that found him and another guy that was with the Whammer on the train made a bet with each other. The bet was that Roy could not strike the Whammer out on three straight...

Words: 1841 - Pages: 8

Free Essay

Information

...Course: Core Skills Module: Data Management Topic: Basic Operations Topic Objective : 1. To create an awarness about the need of data management in enterprises. Problem Scenario Problem Characteristics 1. Should have multiple data enough to realize the need for data management. Sample Problem Scenario 1: Capture the data at the Customer registration desk of a bank. Sample customer profile is given in the Customerprofile_roleplay.ppt. Facilitator can either give a hardcopy of the profile to selected participants and conduct a roleplay with one participant acting as customer desk person or show the profile on the screen and ask participants to capture the data on their notepad. Sample Problem Scenario 2: Capture the data at the inventory receiving desk of a retail shop. Sampe product profile is given in the ProductList_roleplay.ppt. Ask participant to play the role of inventory desk person and capture the product details. Sample Problem Scenario 3: Capture data at the ticketing desk of an airlines. Sampe people profile is given in the PeopleTravel_roleplay.ppt. Ask participant to play the role of travel desk person and capture the person details. Activities / Roleplays : Customer registration desk data managenment can be conducted as a role play / activity in the session. Roleplay : Step1:Select two particpants as the customer registration desk agents for two banks. Brief them on the role of data collection in notebook sitting at a desk...

Words: 446 - Pages: 2

Premium Essay

Reaction Paper in Top Secret Billlionaire

...REACTION PAPER At the age of 16, what are you doing at this age? Ordinary teenagers at this age used to go to school particularly high school, and enjoy their teenage years. Aside from this routine, teenagers may earn money by different stuffs around them. Most of the teenagers enjoy playing online computer games as for now. And who knows you can use this stuff to earn money and lead your first step to become a successful entrepreneur or I should say technopreneur. Like Ittipat who is now a successful businessman. I just can’t imagine how these young people became successful in their life in a simple way like using technology. Ittipat made his first step when someone offer the money to buy the equipment of the online game he was addicted. Of course that way is illegal but he does not think the risk about that. Maybe this is the starter for Top to think about the business. But likes the other gamer addictive he forget his duty as a student, always playing game every day. Because of that he always get low score in his school and he didnt make up to enter state university of Thailand. Until his account became unable to use because of the transaction that he did in the game. And one day when he bought some DVD units but he was cheated by the seller of the DVD. But he didn’t give up. He try other business and like the other successful businessman, he went through many struggles in life like his family go to Shanghai because of the debt in bank, broke up with her girlfriend and many...

Words: 621 - Pages: 3

Free Essay

Cuba

...long restless hours, we landed in Mexico City, only to wait another 3 hours before getting on another plane. Finally arriving to our destination, Cuba, we hopped off the plane only to be surprised by the scorching heat and insane humidity. We were all drenched in a puddle of sweat while just standing motionless waiting for our luggage. Arriving at the hotel we hit the pool for the rest of the day. Next morning we arrived at the field not knowing what to expect. I was pitching the first game. I felt so honored to be given the special opportunity to pitch in the very first stadium where the very first game was played in Cuba. In between innings my teammates would go through a case of water like it was nothing. We were trying hard to play in the scorching weather. I was literally dying in the mound, there was an inning where I ran out of air and was purple! I took about a million puffs of the inhaler and got back on the mound. I am proud to say that I was the first pitcher to ever throw a complete game shutout on that team in history!       on this trip I realized how much I have and how bad I take for granted. It was very hard for me to see kids playing just as good or even better than us without any proper equipment! Kids playing in sandles, torn up cleats , ripped up gloves shorts or sweats. I made many friends and I told them how embarrassed I was to have what I have and not realize how lucky I am, so I gave everything that I had away. I...

Words: 429 - Pages: 2

Premium Essay

Sports Fans

...their mentality is they better win this game and if they lose its then end of the world and puts a lot of the people in bad moods. This happens on the daily basis. Sports fans thrive for the excitement of the games. The excitement of the games and the atmosphere of the stadium bring them in to a whole different world. The fans that take it the most seriously are definitely soccer, baseball, hockey and football fans the most. The die-hard fans care about every game that is played by their team. Most of the time they will take the hard fought loss as if they are part of the team. People are crazy about sports, they’re die-hard fanatics, which sometimes care more about sports then their actual life. The biggest sports fans would have to be football; they go all out for their team. People plan their day around the game by getting to the field to barbeque and tailgate before the game. Most of the time it will be two to three hours before the game. Even some times people will just get to the stadium to tailgate and be in the atmosphere of everyone else and not go into the game because they don’t have tickets. Football fans are crazy they will throw parties in the parking lot before and after the games. They also have fans that paint their bodies and stand out in the freezing cold when normal people would be bulled up in cloths. Football Fans are crazy but that is just the way they are. People will skip out on all sorts of events for game day just because they are that dedicated...

Words: 842 - Pages: 4

Free Essay

Jjbinks

...Quebec This moment in my life took place in October-April 2012. The final minutes of the game in October we were about to win a paid trip to Quebec City to play in the biggest hockey tournament in the world, and we would be sponsored by the Colorado Avalanche Pro hockey team. We did it, we just won the Quebec Qualifier. It was a long 5 months of waiting for our gear to arrive. We had NHL stock jerseys that were exactly the same as the Avalanche wore, we got the same tracksuits, pants covers , and winter gear for the cold Quebec weather and the proud name of the JR. Colorado Avalanche. We had 1 more month of waiting and we would be playing the best teams from around the globe as we would be fighting to be crowned the best PeeWee team in the world. The 6 months of waiting were over and now we only had the traveling, we had the worst flight there it was a total of 7 hours of flying to Montreal from Dallas. We arrived at the Montreal airport at about 11:00 - 12:00 am, then we had to then go through customs, we were finally in Montreal Canada. I guess we had it lucky the other flight lost their bags in Chicago, but they arrived the next day. Now, all that was left was the 2 hour bus drive to Quebec. After the 10 hours of crazy travel we arrived at the Fairmont hotel which was the nicest hotel I have ever seen, if not the nicest 5 star hotel in the world. It used to be a castle for royalty and is surrounded by stone walls and cannons are still visible. Everyone was so...

Words: 895 - Pages: 4

Premium Essay

Tech Good or Bad

...Introduction: Computer games have seriously caught the attention of Mass Media and nowadays every channel considers its duty to remind people how much damage these games cause to children and adults. The increasing amount of games with violent scenes sock the society and makes it very aware of them.It is already common knowledge that violent games cause violence in people. This fact is not even doubted by the majority of people. Every other person says that the reason lies in games being too close to reality. The opinion that games make violent actions normal for the player and therefore make the player pitiless can be often heard. In this case the game is the cause of violence and the act of violence by itself is a consequence. And can real-life violence exist in the reality of a game? Is the transfer of the definition of “violence” with all its peculiarities from one world to another justified only according to the external similarity of these two worlds? Games originally are entertainment. Contemporary games are very realistic and for this reason they are a source of great experience for the player and develop the imagination. Games are entertainment and even more then that. In addition, the statistics of the New York University lead by Green and Bavelier claim that the player preferring active games get an improvement of some types of brain activity, related to processing of visual information. In particular, game players cope with problems of simultaneously tracking several...

Words: 555 - Pages: 3

Premium Essay

Role Playing

...1 Using role playing in the classroom has many benefits: Empathy: When students are participating in role play activities, they are likely to be supportive of their classmates as they understand that putting yourself out there in these types of activities makes you vulnerable. This type of supportive and understanding atmosphere increases empathy among the students. Authentic language experiences: Role play activities give students practice communicating in authentic ways and situations. This will give them more confidence when presented with those scenarios when they are outside of class. Memorable learning experience: The process students go through when they are doing a role play activity (creating or learning the dialogue, practicing, presenting) will help solidify the new information they are learning. Dramatic activities provide “some of the richest and most memorable experiences (students) have in their struggle with the some second language” (Celce-Murcia, 71). Adaptable for multiple levels: Role play activities can be modified to fit upper and lower level students within the same activity. Lower level students can stick to the previously generated script and upper level students can modify the dialogue or improvise on their own. Students can take on as much or as little spontaneity as they feel comfortable. Decreases inhibitions: Parrish states that “because learners are taking on a different persona to a degree, they sometimes are less inhibited than they might be...

Words: 1637 - Pages: 7

Premium Essay

The Dreamer

... marvelous experience of my life. Most people that knew me were only bringing me down, including my mother. I never really paid attention to what people had to say because all I ever wanted to do and still do is to be able to play. Only two persons believed in me and to me, that was enough. My dad and my coach were the only ones who were there pushing me to my best both mentally and physically. Although, it took me a bunch of hard work, patience, effort, perseverance and believing in myself once I was in the academy everything fell like heaven to me. Everything started in France that’s where I first started playing. One day I was playing in a tournament a semi final game, while playing against a hard team I went for the ball and I happen to get tackled and injured real badly. My mom who was watching the game was frightened of course thinking the worst that my leg was probably broken because of the swelling. The morning after, I had an appointment with the doctor and I remember him saying, “ no more soccer for the next 3 months you have a second degree sprained ankle. I’m going to need you to rest, ice, compress and elevate your foot at least 3 times a day.” I was devastated knowing that the summer and my chance to go to the academy was only a couple weeks away. My mom was really mad at me for some reason; She didn’t...

Words: 1058 - Pages: 5

Free Essay

Forever Strong

...landed him in court and he was sent to the Salt Lake City juvenile center. Rick met a guy named Marcus Tate that works in the juvenile center as his overseer for his behavior to report back to the judge. As soon as Rick got into the center he got into a fight and started to be basically a bully. Marcus took Rick to Highland to play Rugby. Rick did not like it there and did not want to be a part of anything they did whether it was for the team or community. Kurt, one of the Highland rugby players and captains took an interest into helping Rick and trying to make him a better person and make him comfortable on the team. It took some time but Rick became a part of the team and wanting to do any and everything with and for the team. After a game, some of the players were driving home and they pulled over to the side of the road to help a woman and children with a flat tire. While Kurt was changing the tire, a drunk driver hit and killed him. It hit the team pretty hard but they were able to come together and be even stronger and go to the national championships. Rick then found out that his father played on the Highland Rugby team that won a National Championship in 86 but when he said something to his father about it, he blamed his knee injury on Coach Gelwix because he had him playing at the wrong position that did not allow him to...

Words: 708 - Pages: 3

Free Essay

English

...Life without Television When my family’s only television set went to the repair shop the other day, my parents, my sister, and I thought we would have a terrible week. How could we get through the long evenings in such a quiet house? What would it be like without all the shows to keep us company? We soon realized, though, that living without television for a while was a stroke of good fortune. It became easy for each of us to enjoy some activities alone, to complete some postponed chores, and to spend rewarding time with each other and friends. First of all, with no television to compete for our time, we found plenty of hours for personal interests. We all read more that week than we had read during the six months before. We read as a family, but we also read stories on our own. Reading stories as a family brought us closer together it seemed. We told stories of our daily encounters. We even learned of stories from our family history. We each also enjoyed some hobbies we had ignored for ages. Our family enjoyed nice outdoor activities- such as basketball, baseball, and golf. We all learned that we were in fact, a very competitive family. We even learned out to sew and knit in our spare time. We enjoyed old activities as well as learning how to do new ones. In addition, my sister and I both stopped procrastinating with our homework. Our grades improved tremendously. We learned that we could help each other out and our homework became easier. We also learned that it is easier...

Words: 846 - Pages: 4

Premium Essay

The Hunger Games

...from you family and friends? Been forced into a game where to stay alive is the only way to win? That is what the hunger game is. A violent game that 24 contestants are chosen to fight one another and the winner will never have to work again. In the Hunger games Suzanne Collins uses characterization to show how Katniss uses survival techniques the love for her family and friends and tested her trust to the people around her. The love Katniss show in the book is very relevant right at the beginning of the book when Prim, Katniss younger sister, is choose to be in the hunger games. Katniss’s love for her sister propels her to volunteer and take Prim’s place in the Hunger Games. She knows that if she goes into the hunger games she will die but does it anyway. Katniss doesn’t just love her sister she also loves her mom, the town she lives in, and a boy named Gale. She desprentaly want to go home once she leaves and fights for her freedom to go home throughout the book. Her relationship with gale is confusing to her but reader know that she loves him “Finally, Gale is here and maybe there is nothing romantic between us, but when he opens his arms I don't hesitate to go into them” (Collins 38) She tries to deny it but readers should be able to figure it out. Katniss knows how to survive and survival is the key factor to winning the hunger games. From the beginning you know that Katniss can hunt and this helps win the hunger games but survival is not just hunting its being smarter...

Words: 369 - Pages: 2