Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a game of Rock, Paper, Scissors in which the users is playing against the

ID: 3763644 • Letter: C

Question

Create a game of Rock, Paper, Scissors in which the users is playing against the computer. The user has the option to create an account and log-in before playing. If a user is logged in then the results of the games are stored in a database. The user can also view a scoreboard with the list of users and the number of times they have won against the computer. The game should be implemented in PHP and linked to from your CS 290 page. You are encouraged to be creative and unique in your implementation. Your final project also requires user accounts and log in capability, so you can design this assignment in such a way that it is easily reused for your project. The minimum requirements for this assignment:

A sign-up page where users can sign-up for an account. The required information is first name, last name, user name and password. You may add more fields. The passwords are combinations of letters and digits that must start with an uppercase letter and end with two digits. At a minimum use sha1() to hash the passwords.

A log-in page. A user with an account can log with their user name and password. If a user is logged in a personalized greeting appears at the top of each page.

A logout page with appropriate message.

Game page very similar to the JavaScript version except that the user will use a form for submission. The user selects either a rock, paper or scissors. You have many options on how to prompt the user some possibilities are entering text, selecting a button, etc. The computer randomly chooses a rock, paper or scissors. Generate an appropriate message saying whether the user or the computer won (or whether it’s a tie). Include instructions for your game on your web page.

If a user is logged in then the outcome of the game is stored in the database. Allow the game to be played multiple times and display the total number of games won by the user and the number won by the computer. A scoreboard page with a list of all users by name and their number of wins sorted in decreasing order. All pages should have the same navigation, header and footer.

Explanation / Answer

import java.util.Random;
import java.util.Scanner;

public class RPS
{
public static void main(String args[]){

String chance, chance1;
int ch = 0;
Random r = new Random();
ch = r.nextInt(3);

System.out.println("Choose: Rock, Paper or Scissors.");
Scanner userChance = new Scanner(System.in);
chance1 = userChance.next();
chance = chance1.toLowerCase();

switch (ch){
case 0:
String ch1 = "rock";
System.out.println("System chose Rock");
if (chance.matches(ch1)){
System.out.println("Its a tie!");

}
else if (chance.matches("paper")){
System.out.println("You win!");

}
else if (chance.matches("scissors")){
System.out.println("You lose!");
}
else {
System.out.println();
System.out.println("ERROR: Please choose Rock, Paper or Scissors");
}
break;
case 1:
String ch2 = "paper";
System.out.println("System chose Paper");
if (chance.matches(ch2)){
System.out.println("Its a tie!");

}
else if (chance.matches("scissors")){
System.out.println("You win!");

}

else if (chance.matches("rock")){
System.out.println("You lose!");
}
else {
System.out.println();
System.out.println("ERROR: Please choose Rock, Paper or Scissors");
}
break;
case 2:
String ch3 = "scissors";
System.out.println("System chose Scissors");
if (chance.matches(ch3)){
System.out.println("Its a tie!");

}
else if (chance.matches("rock")){
System.out.println("You win!");

}
else if (chance.matches("paper")){
System.out.println("You lose!");
}
else {
System.out.println();
System.out.println("invalid: Please choose Rock, Paper or Scissors");
}
break;


}

}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote