this is a part of a bigger project to make a hangman game. this is to set up the
ID: 3658677 • Letter: T
Question
this is a part of a bigger project to make a hangman game. this is to set up the letters in the alphabet available and not available. please help me, if even a little i would greatly appreciate it. if you can guid me through what each should look like or if i use a for each loop or an arraylist. please help!1. make an AlphabetPanel class and implement the following:
a. Shows all of the letters of the alphabet (using a Text object for each letter)
b. reset this is a part of a bigger project to make a hangman game. this is to set up the letters in the alphabet available and not available. please help me, if even a little i would greatly appreciate it. if you can guid me through what each should look like or if i use a for each loop or an arraylist. please help!
1. make an AlphabetPanel class and implement the following:
a. Shows all of the letters of the alphabet (using a Text object for each letter)
b. reset
Explanation / Answer
So anytime you have a programming project, the key is to break the problem down into smaller problems. The philosophy of Object Oriented Programming supports this. The first thing I do is think of the objects my program will need. For instance if I were making a car program, I would create car object that would be compromised of wheel objects, a steering column object, drive-train object, etc. For your project, you might make these objects: 1.) A word object which holds a game word. This might contain methods for checking to see if a letter belongs in the word. 2.) You will need your AlphabetPanel object which will probably contain a word object (The one currently in play). The AlphabetPanel object might contain a method for adding a new word object. Usually for larger programs it is a good idea to separate logic from presentation from input, but for this case you will probably be alright putting input logic in your AlphabetPanel class. Hope I was a little bit of good direction. I know I rambled a bit. here is the code for you :) package Test; import java.util.ArrayList; import java.util.Scanner; public class Hangman{ public static void main(String [] agrs){ ArrayList vocab = new ArrayList(); vocab.add("this"); vocab.add("program"); vocab.add("really"); vocab.add("works"); vocab.add("fine"); int number = (int) (Math.random()*5); //i used 5 since i added 5 words to vocab before. change it accordingly String option = vocab.get(number); begingame(option);} private static void begingame(String option) { boolean status = true; char[] question = option.toCharArray(); char[] nextString = new char[option.length()]; for(int y=0;yRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.