i hope you have taken a look at the links i asked you too , however , sometimes an example explains best. i modified your code a lot , and instead of all the classes , you have just one class now , the char_array{} class renamed to hangman ( just felt that to be more in place with things ) and the other classes you used to have , iv converted them into methods under the hangman class.
here is the code: (this is a basic stuff that will get you started with ideas)
i kept the chosen word as "pizza" as u'll see in the code , go ahead run it , put the words of pizza , and see what happens.
import java.util.*;
public class hangman {
private static String[] words = {"insert","moron","fool","bored","crazy","hello","nice","word","brother","senior","junior",
"glasses","tiny","floor","code","internet","lake","sport","prince","aunt","seven","cartoon","trump","zebra","chalk",
"random","person","movie","place","thing","rabbi","chest","hairy","clothes","close","open","closed","filled",
"waste","find","easy","hard","pitch","base","come","twins","cracka","whatever","keyboard","actually","alabama","sixteen","computer","telephone","habitat","hangman","java" };
public String chosenWord;
public String x;
public int counter = 0;//variable to increase in case of double letter. Added to counter in main function.
public hangman(){
double r = 1 + Math.random()*words.length;
// chosenWord = words[(int)r]; // eventually this should be used
chosenWord="pizza"; // but its good to use what you know while building n testing your code.
// x = b;
}
public void checkInput(Scanner is){
boolean[] pos = new boolean[chosenWord.length()];
int counter = 0;
while(counter!=chosenWord.length()){
System.out.println("\n enter letter: ");
String ip = is.nextLine();
for(int i = 0 ; i < pos.length ; i++){
if(ip.charAt(0)==chosenWord.charAt(i)){
pos[i] = true;
counter++;
}
}
int i = 0;
while(i<pos.length){
if(pos[i]) …