## CS 115 Lab 4 Logic and Boolean Operators

### 50 Points

Due Sunday, February 11, 2018, midnight

Educational goals of this lab - verify that every student can

• design and implementation
• input and output functions
• Boolean operators
• using an if statement

INSTRUCTIONS:

(50 points) Individual Problem: Rock, Paper, Scissors

Imagine there are two players who can both choose either Rock (R), Paper (P), Scissors (S). Each chooses without knowledge of what the other chose. Then both choices are displayed and the winner is determined.

1. If both choose the same one, it's a tie.
2. Then the Rock choice wins over the Scissors, the Paper choice wins over Rock and Scissors wins over Paper.

Ask the first player for a choice. You don't have to check for validity. Clear the screen. Let the second player make a choice. Then report the result, either a tie or Player 1 wins or Player 2 wins.

(20 points) Problem #1: Complete a test plan.

Be exhaustive as far as possible plays. There are 9 of them total.

Half the points is for writing the test cases correctly. Half the points is for your program passing them.

• Description Inputs Expected output
Player 1 Player 2
Player 1, Player 2 tie with S S S It's a tie
ETC.
• Put these test cases as comments at the bottom of the program you write for Problem #2.

(30 points) Problem #2: Write the program

• Write the program in Python to do what is described above. The program needs a prolog, which should contain your name, section, email address (uky.edu).
• The prolog also includes the three P's (purpose, pre-conditions, post-conditions.
• It should also have documentation (comments) in the code.
• Use good, multi-character, meaningful identifiers.
• Write your logic in the most efficient way; you can do it without using 9 separate if's.
• Remember that ALL programs in this class MUST have a main function "def main():" and a call to main "main()" at the bottom of the file.
• How to clear the screen? On a Windows machine, simply print a bunch of blank lines to scroll Player 1's choice off the screen. We will assume Player 2 looks away while Player 1 enters their choice.
• Your program's output should look like the sample run. Note that there is a blank line output between the input statement and the output statement.

Sample Run

```Player 1, Rock, Paper, Scissors? R

(lots of blank lines)

Player 2, Rock, Paper, Scissors? S

Player 1:  R  Player 2:  S
player 1 wins

```

Another Sample run

```Player 1, Rock, Paper, Scissors? S

(lots of blank lines)

Player 2, Rock, Paper, Scissors? S

Player 1:  S  Player 2:  S
It's a Tie
```
• BONUS: (5 points) You can write the logic using Boolean operators to reduce the number of if's needed. If you can get it down to an if with 3 branches, correctly, it's worth 5 extra points.
• Run your test cases to make sure that the program is correct.
• Save the program to a file called lab4.py.