please check up the doc and follow the instructor. please check up the doc and follow the instructor. please check up the doc and follow the instructor.
please check up the doc and follow the instructor.
please check up the doc and follow the instructor.
please check up the doc and follow the instructor.
You have to use idle
thanks Objects
Using files to integrate the key concepts of Python we’ve discussed thus
far.
OVERVIEW
The goal of the this assignment is to find the “word score values” in a game
of Scrabble.
The primary objective to write a script to solve the problem described
below. However, your program should have a “clean” design, meaning that
functions/classes should be used where applicable and code should be
adequately commented.
•
o
▪
o
▪
▪
o
▪
▪
•
o
o
▪
▪
▪
▪
▪
INSTRUCTIONS
Create a class called Scrabble that has the following functions:
A “Constructor” (__init__) that accepts a single filename string for a file
containing letter/value pairs. (An example is attached)
This constructor should read the file and populate a “dictionary” of letter/value for
use with the remaining methods of the class.
A method/function called getWordValue() (in the class) that:
Accepts a single string as a parameter (the word who’s value is to be found)
Returns an integer of the Scrabble “word value” for the provided word.
A method/function called getBestWord() (in the class) that:
Accepts a LIST of word strings.
Returns a single string of the “best” word in the list (the word with the highest
point value)
A “main” function which:
Creates an instance of the Scrabble class from a user supplied filename.
Reads TWO parameters from the command line:
A file name containing the tile names (as illustrated in the attachment, of course,
feel free to test your own values.)
A word (or list of words):
If the user enters a single word, display the point value of that word.
If the user enters a list of words (multiple words separated by commas), displays
the best word in the list.
As a clarificarion of what your main method might look like:
NOTE: THESE ARE JUST FRAGMENTS!!!
# Create a new scrabble scoring object
scoreMaker = new Scrabble( )
# if only a single word…
wordScore = scoreMaker.getWordValue( enterd word> )
# if a list of words…
(word, wordScore) = scoreMaker.getBestWord( )
# Display the appropriate output….
EXAMPLE
LAB5.py c:temptiles.txt apple
World value of apple is 9.
LAB5.py c:temptiles.txt apple,squash
Bast value is squash with 18.
Purchase answer to see full
attachment
Leave a Reply
Want to join the discussion?Feel free to contribute!