Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-13-2012, 02:52 AM   PM User | #1
bballrmx
New to the CF scene

 
Join Date: Dec 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
bballrmx is an unknown quantity at this point
Exclamation Basic Java Class Help

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)
}

}
bballrmx is offline   Reply With Quote
Old 12-13-2012, 02:30 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Quote:
Originally Posted by bballrmx View Post
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.
In which case its likely time to contact a department head or dean. Instructors are paid to assist you in the learning process. If you are a beginner, you shouldn't be using GUI's in the first place.

Since you are using a gui though, the answer is simple: you don't put that in your main methods at all. You attach the event handlers for the keydowns or add a submit button and a ActionListener and chain the events to the method provided by the GuessPhrasePanel. So the main (which I wouldn't put in a panel class) is responsible for instantiating the frame, adding this panel, and attaching the listeners it requires.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Tags
eclipse, java

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:00 PM.


Advertisement
Log in to turn off these ads.