Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Bizzare Scrabble Project The board game scrabble works by assigning points to wooden tiles arranged in cells on a board. It's described here: Scrabble. We'll

Bizzare Scrabble Project

The board game scrabble works by assigning points to wooden tiles arranged in cells on a board. It's described here: 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, what is the highest-(or a highest-) scoring line in the the file? In keeping with the Scrabble style, we'll add double and triple letter scores: any letter that falls at a line (String) position that's evenly divisible by 4 will have its score doubled; and any letter that falls at a line (String) position that's evenly divisible by 9 will have its score tripled. A letter at a position that's evenly divisible by 4 and 9 will have its score doubled, not tripled. All non-letters (e.g., space, comma, etc.) have score 0. Example: the line "now is the time" has a Scrabble score (by our rules) of 29. (Important: verify this with pencil and paper. Note that "n" is at position 0, which is a double letter score.) Your solution is in two classes: A driver class called LineScrabbleDriver, and a class called LineScrabble, which does the heavy lifting for the application. The LineScrabble class should extend Echo, in the standard way we've indicated. Submit the code to these classes in the boxes below.

Echo code:

import java.util.Scanner; import java.io.*; public class Echo{ private String fileName; // external file name private Scanner scan; // Scanner object for reading from external file public Echo(String f) throws IOException { fileName = f; scan = new Scanner(new FileReader(fileName)); } public String getFileName(){ return fileName; } public void readLines(){ // reads lines, hands each to processLine while(scan.hasNext()){ processLine(scan.nextLine()); } scan.close(); } public void processLine(String line){ // does the real processing work System.out.println(line); } }

Project requirments:

You MUST use a try-catch harness in the driver class.

You MUST comment every method with a one line description of the job that method does, and your description must be placed just below the method header line.

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} Notice that this list is in proper format for copying and pasting directly into your program as an int array.

Two sample files are provided: sampletext.txt is silly but useful, and HeartOfDarkness.txt is the famous novella by Joseph Conrad.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions

Question

3. What are potential solutions?

Answered: 1 week ago