i want to out put this to my world:
import java.util.Arrays;
import java.util.Scanner;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.HashMap;
import java.util.*;
import java.util.Scanner;
import java.io.File;
import java.io.BufferedReader;
import java.io.FileReader;
import java.awt.Color;
import greenfoot.*;
/**
* Write a description of class halejadbsa here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class wordsss extends Actor
{
public static Scanner in = new Scanner(System.in);
public wordsss(){
String word = getRandomWord();
String ga;
int tries = 10;
GreenfootImage textTwo = new GreenfootImage(30, 40);
textTwo.drawString("" + word,30, 40);
//String guess = "";
update(toDash(word));
ga = toDash(word);
checkCorrect(word,7);
GreenfootImage text = new GreenfootImage(30, 40);
text.drawString("Your word was " + word,30, 40);
//System.out.println("Your word was " + word);
}
public void act(){
String word = getRandomWord();
String ga;
int tries = 10;
GreenfootImage textTwo = new GreenfootImage(30, 40);
textTwo.drawString("" + word,30, 40);
//String guess = "";
update(toDash(word));
ga = toDash(word);
checkCorrect(word,7);
GreenfootImage text = new GreenfootImage(30, 40);
text.drawString("Your word was " + word,30, 40);
//System.out.println("Your word was " + word);
}
public static void main(Stringargs) {
String word = getRandomWord();
String ga;
int tries = 10;
String guess = "";
update(toDash(word));
ga = toDash(word);
checkCorrect(word,7);
GreenfootImage text = new GreenfootImage(30, 40);
text.drawString("Your word was " + word,30, 40);
//System.out.println("Your word was " + word);
}
public static void update(String word) {
for (int i = 0; i < word.length; i++) {
GreenfootImage text = new GreenfootImage(30, 40);
text.drawString(word + " ",30, 40);
//setImage(text);
// System.out.print(word + " ");
}
}
public static String toDash(String word) {
String a = new String;
//String output = "";
GreenfootImage text = new GreenfootImage(30, 40);
text.drawString("" ,30, 40);
for (int i = 0; i < word.length(); i++) {
a = "_";
}
return a;
}
public static String checkCorrect(String word, int tries) {
String guess;
word = word.toUpperCase();
TreeSet<String> tree = new TreeSet<String>();
String copy = new String;
int counter = 0;
int numberTimes = 0;
copy = toDash(word);
while (!toString(copy).equals(word) && tries >= 0) {
guess = in.nextLine();
guess = guess.toUpperCase();
for (String s : toArray(word)) {
if (guess.equals(s)) {
copy = s;
numberTimes++;
}
counter++;
}
if (isAlreadyIn(guess, tree)) {
GreenfootImage text = new GreenfootImage(30, 40);
text.drawString("You've already guessed that before",30, 40);
//System.out.println("You've already guessed that before");
}
tree.add(guess);
if (numberTimes == 0 || !isAlreadyIn(guess, tree)) {
tries--;
}
//System.out.println("d: " + toString(copy) + "w: " + word + "B: " + numberTimes);
GreenfootImage textTwo = new GreenfootImage(30, 40);
textTwo.drawString("Tries left: " + tries,30, 40);
//System.out.println("Tries left: " + tries);
numberTimes = 0;
counter = 0;
update(copy);
}
return toString(copy);
}
public static String toString(String s) {
String output = "";
for(String str: s) {
output=output+str;
}
return output.toUpperCase();
}
public static String toArray(String s) {
s = s.toUpperCase();
String sa = s.split("");
return sa;
}
public static String getRandomWord(){
String randWord = "a";
try {
while (randWord.length() <= 3) {
ArrayList<String> a = new ArrayList<String>();
FileReader in = new FileReader("/Users/ShivamJanda/Desktop/verbs.txt");
BufferedReader br = new BufferedReader(in);
String line;
while ((line = br.readLine()) != null) {
a.add(br.readLine());
}
Random r = new Random();
randWord = a.get(r.nextInt(a.size()) + 1);
in.close();
}
}
catch (IOException e) {
System.out.println("Error occurred.");
}
return randWord;
}
public static boolean isAlreadyIn(String s, TreeSet<String> tree) {
for (String str : tree) {
if (str.equals(s)) {
return true;
}
}
return false;
}
}

