The board game scrabble works by assigning points to wooden tiles arranged in cells on a board. It's described here:http://en.wikipedia.org/wiki/Scrabble. We'll simplify this considerably, and consider the following question. We begin with the letter-scoring scheme from Scrabble: a = 1, b = 3, c = 3, d = 2, ..., z = 10. Given a text file - a novel for example, and a word size, say 7 characters, what is the highest-(or a highest-) scoring word in the the file of that word size?
Your solution should include two files: A driver, which we provide below, and which you must use, and a file called Scrabble.java, which does the heavy lifting for the application. The Scrabble file should extend Echo, in the standard way we've indicated (it can also extend the LineReader class from Chapter 11 of the text).
Tips:
Make sure you read Chapter 10 of the text as a prelude to doing this problem.
Here is a list from a to z of the letter scores from Scrabble:
{1,3,3,2,1,4,2,4,1,8,5,1,3,1,1,3,10,1,1,1,1,4,4,8,4,10}
It's far easier to convert lines of text to lowercase before processing.
Use a StringTokenizer object to chop up a line into words.
Handle characters that show up inside words, such as apostrophe and hyphen this way: treat a word like "can't" as a five character word, and score the apostrophe as 0. Also, use this String as the second parameter to your StringTokenizer constructor: ",.?! {}[];:". The result of using this String will mean that a word like "students'" (note apostrophe at end) should have length 9.
This is the driver they have given us to use:
import java.util.*;
import java.io.*;
public class ScrabbleDriver{
public static void main(String args[])
{
try{
Scanner s = new Scanner(System.in);
System.out.println("enter file name, then word size");
String f = s.next();
int size = s.nextInt();
Scrabble scrab = new Scrabble(f,size);
scrab.readLines();
scrab.reportWinner();
}
catch(Exception e)
{System.out.println(e);}
}
}
I am not sure how to go about coding this so if anyone could help that would be great.