T-106.1212 Grundkurs i programmering

Rond 4, uppgift 2

Nivå och poängvärde:A 50
Kort beskrivning:Vi lägger till bitarna som fattas.
Vad vi lär oss:Att läsa programkod.
Frihet i implementationen:Liten. Här följer man instruktionerna till punkt och pricka.
Realism:Låg. Ett sådant här problem stöter man nog inte på i verkligheten.
Utmaning:Inte den lättaste av uppgifter. Det kan vara svårt att tolka instruktionerna.
Arbetsmängd:Tämligen lätt. De flesta kräver en timme eller två.

Obs!

Vi fortsätter med "Hänga Gubbe".

Uppgiftsbeskrivning

Gör föregående uppgift före detta, så att du kan använda bitarna man konstruerar där. I modellösningen till uppgift 2.5 finns ett botten där förra uppgiftens delar saknas. I filen pieces.py finns alla "pusselbitarna" som saknas. Organisera dem i rätt ordning och på rätt plats så att du får ett fungerande program. Du ska alltså klippa och klistra från pieces.py till hanging_man.py, det räcker inte med att göra en import pieces. Ersätt de gamla funktionerna med de nya.

Då du testar funktionen, borde det skriva ut följande: Början och instruktioner:
Welcome to play Hanging man!
Use lower case letters (no scandinavians)

Word to guess: _________

Options:
l  guess a letter
w  guess the word
i  instructions
q  quit

Give your choice (l/w/i/q):
i
I'm thinking about a word and your task is to
guess that word by giving letters. If you give a correct
letter, all instances of the letter in the word, will be
shown. If you give a wrong letter, you are one step closer
to be hanging. Also, if you give a letter that has already
been used, hanging is closer. Underscores in the word 
represent missing letters. If you think, that you know
the word before the last guess is used, you can give it.
When the picture is like following, your time has ended.


+-----+
|     |
|     O
|    /|\
|    / \
+-------
|

Word to guess: _________

Options:
l  guess a letter
w  guess the word
i  instructions
q  quit

Give your choice (l/w/i/q):
l

Bokstaven fel och rätt:

Give your choice (l/w/i/q):
l
Give your guess:
y

Miss
+-----+

Word to guess: _________

Options:
l  guess a letter
w  guess the word
i  instructions
q  quit

Give your choice (l/w/i/q):
l
Give your guess:
s
+-----+

Word to guess: s________

Options:
l  guess a letter
w  guess the word
i  instructions
q  quit

Give your choice (l/w/i/q):

Ordet fel och rätt:

Give your choice (l/w/i/q):
w
Guess the word:
something
+-----+
|     

Word to guess: s________

Options:
l  guess a letter
w  guess the word
i  instructions
q  quit

Give your choice (l/w/i/q):
w
Guess the word:
sunflower
+-----+
|     

Correct guess!
Avbrytandet av spelet:
Options:
l  guess a letter
w  guess the word
i  instructions
q  quit

Give your choice (l/w/i/q):
q
You ended the game.
Spelet slut med att gissa bokstäverna rätt:
Word to guess: sunflowe_

Options:
l  guess a letter
w  guess the word
i  instructions
q  quit

Give your choice (l/w/i/q):
l
Give your guess:
r

Correct guess!
Spelets slut när man gissat fel för många gånger:
Word to guess: s________

Options:
l  guess a letter
w  guess the word
i  instructions
q  quit

Give your choice (l/w/i/q):
l
Give your guess:
k

Miss
+-----+
|     |
|     O
|    /|\
|    / \
+-------
|

+-----+
|     |
|     |
|     O
|    /|\
+--+ / \
|  |
You kicked the bucket!

Inlämning

Lämna in hanging_man.py i Goblin.