I was searching the web looking for easy projects to do in order to gain a little bit of experience with the language and I stumbled upon a thread on this website that prompted a "Rock, Paper, Scissors" application. This looked like fun so I decided to try to make one on my own using the knowledge of Java I had up to this point.
As I was writing the code and running the application to test/debug it, I noticed that it put a huge lag on my system to type in code or run the program, so I figured I was doing things the complicated way, giving the computer more to read than it needed.
Any help, tips, advice, suggestions, criticism or comments will be appreciated! (Particularly help with decreasing the amount of lag the program puts on my system, given the problem isn't my hardware.)
Here's my code:
import java.util.Scanner;
import java.util.Random;
public class stuff {
public static void main(String args[]){
Random dice = new Random();
Scanner input = new Scanner(System.in);
Scanner input2 = new Scanner(System.in);
String uchoice;
int compchoice;
String continueRunning= ("Yes");
do{
System.out.println("Welcome to Ace's first java game!");
System.out.println("Type in Rock, Paper, or Scissors to make your selection: ");
uchoice = input.nextLine();
compchoice=dice.nextInt(3)+1;
if(uchoice.equals("Rock")&& compchoice == 1){
System.out.println("You and the computer both selected Rock.");
System.out.println("Tie game, sir.");
}
else if(uchoice.equals("Rock")&& compchoice == 2){
System.out.println("You selected Rock and the computer selected Paper.");
System.out.println("You lose. Sucker.");
}
else if (uchoice.equals("Rock")&& compchoice == 3){
System.out.println("You selected Rock and the computer selected Scissors.");
System.out.println("You win!");
}
else if (uchoice.equals("Paper")&& compchoice == 1){
System.out.println("You selected Paper and the computer selected Rock.");
System.out.println("You win!");
}
else if (uchoice.equals("Paper")&& compchoice == 2){
System.out.println("You selected Paper and the computer selected Paper.");
System.out.println("Tie game, sir.");
}
else if (uchoice.equals("Paper")&& compchoice == 3){
System.out.println("You selected Paper and the computer selected Scissors.");
System.out.println("You lose. Sucker.");
}
else if (uchoice.equals("Scissors")&& compchoice == 1){
System.out.println("You selected Scissors and the computer selected Rock.");
System.out.println("You lose. Sucker.");
}
else if (uchoice.equals("Scissors")&& compchoice == 2){
System.out.println("You selected Scissors and the computer selected Paper.");
System.out.println("You win!");
}
else if (uchoice.equals("Scissors")&& compchoice == 3){
System.out.println("You selected Scissors and the computer selected Scissors.");
System.out.println("Tie game, sir.");
}
else{System.out.println("Try using a captial letter, dork.");}
System.out.println("Would you like to play again? Type Yes or No.");
continueRunning=input2.nextLine();
}
while(continueRunning.equals("Yes"));
}
}
Thanks again!
-Java Hardstyle
I just noticed that BASIC is another programming language and that I have no idea why I capitalized that, as I mean it as an adjective referring to my game. This game was definitely built with Java. /Facepalm

New Topic/Question
Reply



MultiQuote





|