Professional Documents
Culture Documents
CMPT 120, Fall 2008, SFU Burnaby Instructor: Diana Cukierman
CMPT 120, Fall 2008, SFU Burnaby Instructor: Diana Cukierman
This is a 2 team people work (you can also work individually if you prefer so).
While you can discuss generalities with colleagues from other teams about this
exercise, you cannot develop the same code, nor share code among teams, nor
obtain code from other sources.
Submission deadline of the whole project: Tuesday October 28, at 5 pm. It will
only be an electronic submission. You are encouraged to start working on this
right away. Examples related to this project may be discussed during lectures.
b. As an extra feature (providing you bonus points) the program can offer
the user two options: level 1 – no repeated letters in the codeword
allowed, level 2 – repetitions allowed. (As a first version (or
perhaps your only version) you are recommended to not control this –
which makes it harder to the user but easier to the program.)
e. Then the user will try to guess the secret codeword with several
trials (not more that the established maximum), by guessing a whole
tentative codeword at a time.
f. After each guess, the user will be shown how many letters from his/her
guess there are in the right position and how many letters from
his/her guess there are in the wrong position. The program will also
show the user all the guesses and the outcomes played so far
(associated to this codeword). (See example below)
h. At the end of all the games (when the user does not want to play any
more) the program will inform to the user how many games the user
played, how many the user won and how many the user lost.
Assume the program chooses the alphabet {a,e,i,x,y,z} and codeword ‘axey’.
As a first step the program will show to the user the alphabet {a,e,i,x,y,z}
and it will inform that the codeword has 4 letters.
Assume the user proposes the codeword as his/her first guess: ‘aeix’.
Then the program should inform that there is/are:
¾ 1 correct letter and position [that’s the “a”] and
¾ 2 correct letters in wrong position [that’s the “e” and the “x”].
As well, the program should show the state of the game so far including
information displayed somehow like the following:
Then the user tries again proposing a new codeword. Let’s assume the user
provides the codeword: “axyz”
Then the program should inform that there is/are:
¾ 2 correct letters and position [that’s the “a” and the “x”] and
¾ 1 correct letter in wrong position [that’s the “y”].
At this point, the state of the game so far to be displayed should be:
and so on…
if the user wins or the number of guesses are over, the game is over and the
user can play new games.
3. Exercises/activities to do in preparation for the project: (you will have
to submit parts of these exercises only when submitting the whole project)
b. Think about how you would implement this game. Think about a top level
description of the solution. Think about which information you need to
be able to run this game: which variables you need to control the
execution of the game and which variables you need to do calculations.
If some information is not provided in this description, think which
could be reasonable assumptions. Think of questions you may have about
the game.
d. Design another top level flow chart diagram describing the same game
as in part (3c), but additionally allowing that the user can play many
games (i.e. guessing different codewords)
ii. Given a variable which we can call length and a list (or a string)
of characters, it generates a random codeword containing randomly,
as many characters from that list (or string) as the value in
length, in any order.
h. Keep track (a log) in a text file of what you do/work on to help you
keep control of the project and distribute tasks in case of working as
a team. You will be asked to submit some report about how you
organized your work and this log will provide you that information.