Difference between revisions of "CSC111 Homework 3 2014"
(→Requirements) |
|||
Line 46: | Line 46: | ||
<br /> | <br /> | ||
− | =Problem #3: Mother | + | =Problem #3: Mother Teresa and Father Christmas= |
<br /> | <br /> | ||
This program will be called '''hw3c.py'''. | This program will be called '''hw3c.py'''. | ||
Line 64: | Line 64: | ||
<br /> | <br /> | ||
<br /> | <br /> | ||
− | We now add a twist: if the user enters the words '''Mother | + | We now add a twist: if the user enters the words '''Mother Teresa''' or '''Father Christmas''' embedded in a sentence, however, we will consider that these are not references to the user's family, and the program will output the same generic answer and not mention family. |
It's more challenging that it looks! | It's more challenging that it looks! | ||
Line 83: | Line 83: | ||
--''I would like to hear more about your family''<br /> | --''I would like to hear more about your family''<br /> | ||
<br /> | <br /> | ||
− | --''Please tell me what's on your mind: '' '''Mother | + | --''Please tell me what's on your mind: '' '''Mother Teresa is real, Father Christmas not!'''<br /> |
--''Glad to hear that!''<br /> | --''Glad to hear that!''<br /> | ||
<br /> | <br /> | ||
− | --''Please tell me what's on your mind: '' '''My mother and | + | --''Please tell me what's on your mind: '' '''My mother and Teresa went shopping'''<br /> |
--''I would like to hear more about your family''<br /> | --''I would like to hear more about your family''<br /> | ||
<br /> | <br /> | ||
− | --''Please tell me what's on your mind: '' '''Mother likes Mother | + | --''Please tell me what's on your mind: '' '''Mother likes Mother Teresa'''<br /> |
--''I would like to hear more about your family''<br /> | --''I would like to hear more about your family''<br /> | ||
<br /> | <br /> |
Latest revision as of 12:09, 13 March 2015
--D. Thiebaut (talk) 21:23, 12 February 2014 (EST)
This assignment asks you to add new levels of testing with if-statements in the Rock-Paper-Scissors game. This assignment must be performed in pair-programming mode. You need a different partner than the partner you had for Homework 2. Only one set of programs needs to be submitted for the two partners, and should be submitted by the same partner.
Contents
Problem #1: Adding a mug to the game
This program will be called hw3a.py.
This program will allow the user to play a more sophisticated game where there is another option: a mug!
The new rules are the same as for the Rock-Paper-Scissors game, but with these additions:
- Scissors fall in mug, and mug wins
- Paper blocks mug, and paper wins
- Rock breaks mug, and rock wins
Requirements
- Your program should recognize lowercase as well as uppercase inputs from the user.
- You can assume that the user will always enter the correct letters, and they can be upper- or lowercase.
- Your program should let the user play 3 rounds with the computer.
- Your program should keep track of who's is winning and print the winner of the 3 rounds at the end.
- Your program does not need to use loops, but you may use while loops if they make sense enough. Homework 4 is dedicated to while loops.
Problem #2: Test for invalid inputs
Your program will be called hw3b.py.
No mugs in this program!
Your assignment is to take the Rock-Paper-Scissors game from Lab 3 and to make sure it implements the following features (some part of Lab 3's program, some new):
- Your program should let the user play 3 rounds with the computer.
- Your program should keep track of who's is winning and print the winner of the 3 rounds at the end.
- Your program should accept upper or lower case inputs from the user. So r and R should be recognized as meaning Rock. Similarly for the other letters.
- If the user does not enter one of the valid inputs ('R', 'S', or 'P') the program will ask the user to enter a new character. The user has only one chance to correct the mistake. If the character entered the second time by the user is still not one of 'R', 'S', or 'P', the computer will automatically pick a random good character for the user, i.e. one of 'R', 'S', or 'P'.
Problem #3: Mother Teresa and Father Christmas
This program will be called hw3c.py.
It is a continuation of the exercises in Lab 3 where the program had to recognize the words mother or father in the user's input.
Your program must work similarly to the way the program of Lab 3 works: if the user types a sentence where the words mother, father, sister, or brother appear, then the program outputs a response indicating that it detected a family issue:
--I would like to hear more about your family
If the user's input does not contain any of these keywords, then the program outputs some generic sentence of your choice. For example:
--Glad to hear that!
We now add a twist: if the user enters the words Mother Teresa or Father Christmas embedded in a sentence, however, we will consider that these are not references to the user's family, and the program will output the same generic answer and not mention family.
It's more challenging that it looks!
Make sure you test your program well. All types of input will be fed to your program to test it! Below are some example of valid exchanges between the computer and the user. The user input is in bold.
--Please tell me what's on your mind: I love programming in Python!
--Glad to hear that!
--Please tell me what's on your mind: My mother likes programming in Python!
--I would like to hear more about your family
--Please tell me what's on your mind: I read this great story about Father Christmas!
--Glad to hear that!
--Please tell me what's on your mind: My mother likes Father Christmas!
--I would like to hear more about your family
--Please tell me what's on your mind: Mother Teresa is real, Father Christmas not!
--Glad to hear that!
--Please tell me what's on your mind: My mother and Teresa went shopping
--I would like to hear more about your family
--Please tell me what's on your mind: Mother likes Mother Teresa
--I would like to hear more about your family
--Please tell me what's on your mind: Mother
--I would like to hear more about your family
Submission
Always make sure your program runs before submitting it!!!
Make sure your program has a header at the top with
- the name of the program
- your two names
- your two two-letter Id
- a brief description of the program
Submit your programs to this link: cs.smith.edu/~thiebaut/111b/submit3.php. The deadline is Thursday night 2/20/14, at midnight.