Tino APCS

Lab 10.7 StringCraft

Directions

Click here for Lab Directions

Code style

You may write all your methods as static methods in a Driver or you may use separate classes. Either way, your helper functions should work independently and not rely on any attributes.

Coding Workflow

During class, you should already have written top-down code for the main game loop. What remains is to implement the helper functions.

Rather than write the entire program and hope that it works, you should write and test each helper function separately. Treat them each like separate Codingbat problems and write a battery of tests to ensure each helper method works on its own.

For example, let's say you have a stringValue(String str) helper function that calculates and returns the raw value (not including moves) for a given String. Then after writing this function, you should test it thoroughly by running all categories of test cases on it. Something like this:

// No runs or straights
System.out.println("stringValue(R) = " + wordValue("R") + " ...should be 1"
System.out.println("stringValue(RPA) = " + wordValue("RPA") + " ...should be 3");

// Runs only
System.out.println("stringValue(BB) = " + wordValue("BB") + " ...should be 4");
System.out.println("stringValue(CCC) = " + wordValue("CCC") + " ...should be 9");
System.out.println("stringValue(DDDD) = " + wordValue("DDDD") + " ...should be 16");

// Straights only
System.out.println("stringValue(AB) = " + wordValue("AB") + " ...should be 3");
System.out.println("stringValue(GHI) = " + wordValue("GHI") + " ...should be 6");
System.out.println("stringValue(MNOP) = " + wordValue("MNOP") + " ...should be 10");

// Special case runs that wrap around the alphabet
...

// Runs and Straights combined
...

// etc...

All files must incude your name and period in the format PX_LastName_FirstName_Title

You must Sign In to submit to this assignment

Last modified: November 12, 2023

Back to Lab 10.6 Complexuserinput

Dark Mode

Outline