MCPcopy Create free account
hub / github.com/PrajaktaSathe/Java / play

Method play

Programs/Games/HangMan.java:93–134  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

91 }
92
93 public void play() {
94 pickWord();
95 setGuessedWord();
96 setGuess(this.compPick);
97 System.out.println("I am thinking of a " + this.compPick.length() + " letter word.");
98 boolean flag = true;
99 do {
100 if ((this.warning == 0 || this.guesses == 0) || wordGuessed()) {
101 if(wordGuessed()){
102 System.out.println(this.guessedWord);
103 System.out.println("Congrats!");
104 }else{
105 System.out.println("You failed. The word was: " + this.compPick);
106 }
107 flag = false;
108 } else
109 {
110 System.out.println("You have " + this.guesses + " guesses.");
111 System.out.println("You have " + this.warning + " warnings.");
112 System.out.println("Alphabets remaining: " + this.alphabets);
113 System.out.println(this.guessedWord);
114 char guessLetter = inputChar();
115 if (isInPick(guessLetter)) {
116 if (alreadyGuessed(guessLetter)) {
117 System.out.println("You have already guessed this letter.");
118 }
119 else{
120
121 setIndices(guessLetter);
122 updateGuessed(guessLetter, this.indices);
123 removeAlphabet(guessLetter);
124 }
125
126 }
127 else{
128 System.out.println("Wrong Guess!");
129 this.guesses--;
130 }
131 }
132 }while (flag) ;
133
134 }
135
136 public static void main(String args[]) {
137 HangMan h = new HangMan();

Callers 1

mainMethod · 0.95

Calls 11

pickWordMethod · 0.95
setGuessedWordMethod · 0.95
setGuessMethod · 0.95
wordGuessedMethod · 0.95
inputCharMethod · 0.95
isInPickMethod · 0.95
alreadyGuessedMethod · 0.95
setIndicesMethod · 0.95
updateGuessedMethod · 0.95
removeAlphabetMethod · 0.95
lengthMethod · 0.80

Tested by

no test coverage detected