Prog 4:TextTwist

Write a program to play the game of TextTwist. Running the program looks like the following, where user input is shown in bold:

C:\Reed\141\Programs\Prog4TextTwist> ./TextTwist

TextTwist: Guess as many 3 to 6 letter words as you            can using only the supplied letters. Class: CS 141 program #4, Spring 2013 Author: Dale Reed  Instructions: Enter a valid word that is 3 to 6 characters in length that can be formed using the displayed letters. Continue doing this until as many of the words are found as possible within the given time limits. Possible commands are:     x  to exit the game     t  to twist the letters into a different order     s  to set the word to letters of your choosing     c  to cheat, displaying all words  ___     ___     ___ ___     ___     ___ ___     ___     ___ ___     ___     ____ ____    ____    ____ ____    ____    ____ ____    ____    ____ ____    ____    ____ _____   ______   Time Remaining: 60  Score: 0.  Letters to use are: DEOCIL Enter command (x:exit, t:twist, s:set, c:cheat) or word: docile          "docile" IS one of the words. ___     ___     ___ ___     ___     ___ ___     ___     ___ ___     ___     ____ ____    ____    ____ ____    ____    ____ ____    ____    ____ ____    ____    ____ _____   DOCILE   Time Remaining: 56  Score: 8.  Letters to use are: DEOCIL Enter command (x:exit, t:twist, s:set, c:cheat) or word: lied          "lied" IS one of the words. ___     ___     ___ ___     ___     ___ ___     ___     ___ ___     ___     ____ ____    ____    ____ ____    ____    ____ ____    ____    ____ ____    LIED    ____ _____   DOCILE   Time Remaining: 53  Score: 10.  Letters to use are: DEOCIL Enter command (x:exit, t:twist, s:set, c:cheat) or word: cod          "cod" IS one of the words. COD     ___     ___ ___     ___     ___ ___     ___     ___ ___     ___     ____ ____    ____    ____ ____    ____    ____ ____    ____    ____ ____    LIED    ____ _____   DOCILE   Time Remaining: 52  Score: 11.  Letters to use are: DEOCIL Enter command (x:exit, t:twist, s:set, c:cheat) or word: t COD     ___     ___ ___     ___     ___ ___     ___     ___ ___     ___     ____ ____    ____    ____ ____    ____    ____ ____    ____    ____ ____    LIED    ____ _____   DOCILE   Time Remaining: 50  Score: 11.  Letters to use are: ECDLIO Enter command (x:exit, t:twist, s:set, c:cheat) or word: t COD     ___     ___ ___     ___     ___ ___     ___     ___ ___     ___     ____ ____    ____    ____ ____    ____    ____ ____    ____    ____ ____    LIED    ____ _____   DOCILE   Time Remaining: 45  Score: 11.  Letters to use are: COEDLI Enter command (x:exit, t:twist, s:set, c:cheat) or word: lod          "lod" is NOT one of the words or was already found. COD     ___     ___ ___     ___     ___ ___     ___     ___ ___     ___     ____ ____    ____    ____ ____    ____    ____ ____    ____    ____ ____    LIED    ____ _____   DOCILE   Time Remaining: 37  Score: 11.  Letters to use are: COEDLI Enter command (x:exit, t:twist, s:set, c:cheat) or word: c COD     col     die doe     ice     led lid     lie     ode oil     old     ceil clod    code    coed coil    cold    dice dole    idle    idol lice    LIED    loci dolce   DOCILE   COD     ___     ___ ___     ___     ___ ___     ___     ___ ___     ___     ____ ____    ____    ____ ____    ____    ____ ____    ____    ____ ____    LIED    ____ _____   DOCILE   Time Remaining: 25  Score: 11.  Letters to use are: COEDLI Enter command (x:exit, t:twist, s:set, c:cheat) or word: idol          "idol" IS one of the words. COD     ___     ___ ___     ___     ___ ___     ___     ___ ___     ___     ____ ____    ____    ____ ____    ____    ____ ____    ____    IDOL ____    LIED    ____ _____   DOCILE   Time Remaining: 19  Score: 13.  Letters to use are: COEDLI Enter command (x:exit, t:twist, s:set, c:cheat) or word: idle          "idle" IS one of the words. COD     ___     ___ ___     ___     ___ ___     ___     ___ ___     ___     ____ ____    ____    ____ ____    ____    ____ ____    IDLE    IDOL ____    LIED    ____ _____   DOCILE   Time Remaining: 7  Score: 15.  Letters to use are: COEDLI Enter command (x:exit, t:twist, s:set, c:cheat) or word: old          "old" IS one of the words. COD     ___     ___ ___     ___     ___ ___     ___     ___ ___     OLD     ____ ____    ____    ____ ____    ____    ____ ____    IDLE    IDOL ____    LIED    ____ _____   DOCILE   Time Remaining: -15 Sorry, time is up.  Exiting...   Words found are shown in capital letters. COD     col     die doe     ice     led lid     lie     ode oil     OLD     ceil clod    code    coed coil    cold    dice dole    IDLE    IDOL lice    LIED    loci dolce   DOCILE   Score was 16 Thanks for playing, goodbye...

And running the program and setting the word from within the program would look like:

C:\Reed\141\Programs\Prog4TextTwist> ./TextTwist

TextTwist: Guess as many 3 to 6 letter words as you            can using only the supplied letters. Class: CS 141 program #4, Spring 2013 Author: Dale Reed

Instructions: Enter a valid word that is 3 to 6 characters in length that can be formed using the displayed letters. Continue doing this until as many of the words are found as possible within the given time limits. Possible commands are:     x  to exit the game     t  to twist the letters into a different order     s  to set the word to letters of your choosing     c  to cheat, displaying all words  ___     ___     ___ ___     ___     ___ ___     ___     ___ ___     ___     ____ ____    ____    ____ ____    ____    ____ ____    ____    ____ ____    ____    ____ _____   ______   Time Remaining: 60  Score: 0.  Letters to use are: DEOCIL Enter command (x:exit, t:twist, s:set, c:cheat) or word: cod          "cod" IS one of the words. COD     ___     ___ ___     ___     ___ ___     ___     ___ ___     ___     ____ ____    ____    ____ ____    ____    ____ ____    ____    ____ ____    ____    ____ _____   ______   Time Remaining: 55  Score: 1.  Letters to use are: DEOCIL Enter command (x:exit, t:twist, s:set, c:cheat) or word: s Enter the new word to use: recent ___     ___     ___ ___     ___     ___ ___     ____    ____ ____    ____    ____ _____   _____   ______    Time Remaining: 60  Score: 0.  Letters to use are: EERTNC Enter command (x:exit, t:twist, s:set, c:cheat) or word: tee          "tee" IS one of the words. ___     ___     ___ ___     ___     TEE ___     ____    ____ ____    ____    ____ _____   _____   ______    Time Remaining: 52  Score: 1.  Letters to use are: EERTNC Enter command (x:exit, t:twist, s:set, c:cheat) or word: x Words found are shown in capital letters. ere     etc     nee net     ret     TEE ten     cent    rent teen    tern    tree enter   erect   recent   Score was 1 Thanks for playing, goodbye...

You need to know the following concepts in order to write this program:

Everything from the previous programs, single and 2 dimensional arrays, binary search, reading from a file, implementing a timer to test elapsed time.

Hints: