Back to category: Technology

Limited version - please login or register to view the entire paper.

Come up wit Java code for a basic game of hangman

import java.awt.*;
import java.awt.event.*;
import java.applet.*;


public class Hangman extends Applet
{
// if the word list has over 100 words change new char and new string to 200
int wordLen;
char secretword[] = new char [100];
int errorcount=0;
String word;
String msg1="";
String wordList[] = new String [100];


public void init()
{

Font f1 = new Font("Stencil",Font.PLAIN,20);
setFont(f1);
setBackground(Color.black);
setForeground(Color.orange);
addKeyListener(new MyKeyAdapter());

word = getWord();
wordLen = word.length();
for (int i=0;i secretword[i]='_';
}




class MyKeyAdapter extends KeyAdapter{
public void keyTyped(KeyEvent ke){
char ch = ke.getKeyChar();
//showStatus("key Typed = "+ch);
boolean lettercorrect=false;
for(int s=0;s ...

Posted by: Cinthia De Ruiz

Limited version - please login or register to view the entire paper.