CSU Banner

CS 150, Fall 2017

Programming Assignment - P3

Conditionals - If and Switch

Due - September 26th, 2017 at 6:00pm

Late - September 27th, 2017 at 8:00am


Objectives of this Assignment

  1. To write a Java program that determines output based on conditionals,
  2. to practice reading input from the user via the console,
  3. to gain exposure to the Random class, and
  4. to practice writing if statements and a switch block.

Description

This assignment is inspired by the TV show The Big Bang Theory and you will be implementing Rock, Paper, Scissors, Lizard, Spock as a Java program. As Sheldon explains on the show, "Scissors cuts paper, paper covers rock, rock crushes lizard, lizard poisons Spock, Spock smashes scissors, scissors decapitates lizard, lizard eats paper, paper disproves Spock, Spock vaporizes rock, and as it always has, rock crushes scissors."

Game visual

Instructions

Create a Java program called P3 with a class named P3, which after created should contain a file named P3.java in the src folder. All of the Java code you write should be contained in the main method. An example of how you might structure your main method is given below. For this assignment, you must follow the directions below exactly:

Program Structure

// P3 Assignment 
// Author: Russ Wakefield
// Date:   9/19/2017
// Class:  CS150
// Email:  waker@colostate.edu

import java.util.Scanner;

public class P3 {

    public static void main(String[] args) {
        // Declare variables.
	
	// Prompt user for a seed and copy and paste code from step 13.	
	
	// Game instructions, prompt user and assign player's choice variable.	
		
	// Print computer's choice.
		
	// Utilize a switch block with if statements to determine winner.
		
    } // end main

} // end class P3

Sample Output

Your program should print 13 lines, which includes 3 blank lines.

 
Please enter a seed: 10

Which game object do you choose?
For rock, enter 1.
For paper, enter 2.
For scissors, enter 3.
For lizard, enter 4.
For Spock, enter 5.

Your choice: 2
Computer's choice: 3

Scissors cut paper. Computer wins.

---------------------------------
Please enter a seed: 10

Which game object do you choose?
For rock, enter 1.
For paper, enter 2.
For scissors, enter 3.
For lizard, enter 4.
For Spock, enter 5.

Your choice: 3
Computer's choice: 3

Computer generated same choice.  Draw game.

---------------------------------
Please enter a seed: 10

Which game object do you choose?
For rock, enter 1.
For paper, enter 2.
For scissors, enter 3.
For lizard, enter 4.
For Spock, enter 5.

Your choice: 5
Computer's choice: 3

Spock smashes scissors.  Player wins.

---------------------------------
Please enter a seed: 10

Which game object do you choose?
For rock, enter 1.
For paper, enter 2.
For scissors, enter 3.
For lizard, enter 4.
For Spock, enter 5.

Your choice: 1
Computer's choice: 3

Rock crushes scissors. Player wins.
 

Specifications

Grading Criteria


Submit P3.java to Checkin.


CS Banner
CS Building