Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MUST BE WRITTEN IN PERL: PROGRAM SPECIFICATION Rock, Paper, Scissors, Lizard, Spock Game The game is an expansion on the game Rock, Paper, Scissors. Each

MUST BE WRITTEN IN PERL:

PROGRAM SPECIFICATION

Rock, Paper, Scissors, Lizard, Spock Game

The game is an expansion on the game Rock, Paper, Scissors. Each player picks a variable and reveals it at the same time. The winner is the one who defeats the others. In a tie, the process is repeated until a winner is found.

Write a program that lets the user play the game of Rock, Paper, Scissors, Lizard, Spock against the computer. The program should work as follows.

1. When the program begins, a random number in the range of 1 through 5 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. If the number is 4, then the computer has chosen lizard. If the number is 5, then the computer has chosen Spock. (Dont display the computers choice yet.)

2. The user enters his or her choice of rock, paper, scissors, lizard, or Spock at the keyboard. (Please use a menu)

3. The computers choice is displayed.

4. A winner is selected according to the following rules:

If one player chooses rock and the other player chooses scissors, then rock wins. (The rock smashes the scissors.)

If one player chooses scissors and the other player chooses paper, then scissors wins. (Scissors cuts paper.)

If one player chooses paper and the other player chooses rock, then paper wins. (Paper covers rock.)

If one player chooses rock and the other player chooses lizard, then rock wins. (Rock crushes Lizard.)

If one player chooses lizard and the other player chooses Spock, then lizard wins. (Lizard poisons Spock.)

If one player chooses scissors and the other player chooses Spock, then Spock wins. (Spock smashes Scissors.)

If one player chooses scissors and the other player chooses lizard, then scissors wins. (Scissors decapitates Lizard.)

If one player chooses paper and the other player chooses lizard, then lizard wins. (Lizard eats Paper.)

If one player chooses paper and the other player chooses Spock, then paper wins. (Paper disproves Spock.)

If one player chooses rock and the other player chooses Spock, then Spock wins. (Spock vaporizes Rock.)

If both players make the same choice, the game must be played again to determine the winner.

Allow for game to keep being played until user indicates exit. At the end of the game session display number of games played, number of losses and wins of user.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions