I'm trying to figure out how to create a class ScrabbleGame.java that contains the two following methods:
The first method, SpelledIT, consists of the two strings StringTile and StringWord and determines whether tiles set can spell the word, returning true if so & false otherwise.
The second, doubloon, takes a string and checks whether it is a doubloon. Use the toLowerCase method before checking to ignore case.
Please use nested loops not arrays.
/*
* @author Chegg
*
*/
public class ScrabbleGame {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method
stub
// Some Example to Test
Method
System.out.println(SpelledIT("cenimatography","minato"));
System.out.println(doubloon("abba"));
System.out.println(doubloon("Shanghaiingss"));
}
public static boolean SpelledIT(String StringTile,
String StringWord) {
for(int
i=0;i<StringWord.length();i++) {
if(StringTile.indexOf(StringWord.charAt(i)) == -1)
{
return false;
} else {
int charLocation =
StringTile.indexOf(StringWord.charAt(i));
StringTile =
StringTile.substring(0,charLocation)
+
StringTile.substring(charLocation+1,StringTile.length());
}
}
return true;
}
public static boolean doubloon(String checkDoubloon)
{
String
lowerCheckDoubloon=checkDoubloon.toLowerCase();
boolean check = true;
for(int i= 0;
i<lowerCheckDoubloon.length();i++){
int count=0;
for(int
j=0;j<lowerCheckDoubloon.length();j++){
if(lowerCheckDoubloon.charAt(i)==lowerCheckDoubloon.charAt(j))
count++;
}
if (count != 2) {
check = false;
break;
}
}
return check;
}
}

I'm trying to figure out how to create a class ScrabbleGame.java that contains the two following...