Java hangman GuessPrase HELP!?
Create a GuessPhrasePanel class and implement the following (NOTE: Make sure your methods work the same for upper and lower case letters):
a. Has a constructor taking a String guess phrase
b. Shows all the letters in the phrase, initially just showing the underline for all alphabet letters (not the letter as it needs to be guessed). Spaces and other punctuation should be shown with no underline.
c. setPhrase – sets a new phrase to this GuessPhrase object, gets rid of old phrase parts and creates new ones
d. hasLetter – a method that returns whether or not a specified letter is in the phrase
e. revealLetter – a method that reveals or shows a specified letter (if there are more than one of that letter, all should be revealed)
f. isFullPhraseRevealed – returns whether or not the full phrase has been revealed
g. revealFullPhrase – reveals the full phrase
PLEASE HELP IM SO LOST I HAVE NO IDEA WHAT TO PUT IN THE METHOD BODIES AND IN MAIN. im just a beginner and my teacher refuses to offer help.
I was given these instructions and i need to write my own code. this is what i was able to come up with.
i got like 30-40% i think. but i dont know how to finish.
if you can tell me how. to do these parts. what they are supposed to look like. if it needs an if statement or not or something like that. just some guidance im soo lost. please if you can suggest anything at all!
if possible if you can write up the code id really appreciate it, im going to fail the class if i cant get this perfect. IM BEGGING YOU
my code
------------------------------
Code:
import java.io.IOException;
import javax.swing.JPanel;
public class GuessPhrasePanel extends JPanel {
String phrase;
public GuessPhrasePanel (String phrase){
}
public void setPhrase(String p) {
phrase = p;
}
public boolean hasLetter(char c){
return hasLetter(c);
}
public boolean isFullPhraseRevealed(){
return isFullPhraseRevealed();
}
public void revealLetter(char c){
}
public void revealFullPhrase(){
}
public static void main(String[] args) {
GuessPhrasePanel myGuessPhrasePanel = new GuessPhrasePanel;
//(supposed to initialize letters here)
}
}