My game will play 10 rounds, so each time you advance to a new round, the preceding rounds are still visible. Is there anyway to have the console refresh itself so that only the round you are on is visible?
// Rock Paper Scissor Shoot Game
import java.util.Random;
import java.util.Scanner;
public class RockPaperSciccor {
public static void main(String[] args){
int wins = 0;
int losses = 0;
int rnd;
System.out.print("*************************************\n*");
System.out.println(" Rock, Paper, Scissor, Shoot! *\n* \tBy: Alex Hollander \t *");
System.out.println("*\t\t\t\t *");
System.out.print("*************************************\n");
System.out.println("\t\t\t\t\t Instructions:\n\t\t\t\t\t Choose a number 1-3\n \t\t\t\t\t to play the computer.");
// Play's 10 rounds before terminating
for(rnd=10;rnd>=1;rnd--){
//Display's rounds left on the right side
System.out.println("\t\t\t\t\t ____________\n\t\t\t\t\t |1 = Rock |\n\t\t\t\t\t |2 = Paper |\n\t\t\t\t\t |3 = Scissor|");
System.out.println("\t\t\t\t\t ~~~~~~~~~~~~~~");
System.out.println("\t\t\t\t\t|Rounds Left:" + (rnd) + "|");
System.out.println("\t\t\t\t\t ~~~~~~~~~~~~~~");
// Creates the PC, who chooses a random # 1-3
Random GAME = new Random();
int PC = 1+GAME.nextInt(3);
//User input
Scanner input = new Scanner (System.in);
int SCISSOR, ROCK, PAPER;
ROCK = 1;
PAPER = 2;
SCISSOR= 3;
int USER = input.nextInt();
//If the user enters a value greater then 3 or less than 1 it will terminate the prgm
//and display an error msg
while (USER > 3 || USER < 1) {
System.err.println("Incorrect value entered. Restart the Game\nand choose a number 1-3");
return;
}
System.out.println("___________________");
//All Possible Outcomes
//Draw
if(USER == PC){
if(USER == SCISSOR){
System.out.println("You Both Played Scissor");
}
if(USER == ROCK){
System.out.println("You Both Played Rock");
}
if(USER == PAPER){
System.out.println("You Both Played Paper");
}
System.out.println("Draw :\\");
System.out.println("|~~~~~~~~~~~~~~~~~~|");
System.out.println(" Wins: " + wins + "|Losses: " + losses);
System.out.println("|~~~~~~~~~~~~~~~~~~|");
}
//User wins
if(USER == SCISSOR)
if(PC == PAPER){
System.out.println("You: Scissor\nPC: Paper");
System.out.println("Scissor Cuts Paper");
System.out.println("You Win! :]");
wins++;
System.out.println("|~~~~~~~~~~~~~~~~~~|");
System.out.println(" Wins: " + wins + "|Losses: " + losses);
System.out.println("|~~~~~~~~~~~~~~~~~~|");
}
//Pc wins
else if(PC == ROCK){
System.out.println("You: Scissor \nPC: Rock");
System.out.println("Rock Breaks Scissor!");
System.out.println("PC Wins! >:D");
losses++;
System.out.println("|~~~~~~~~~~~~~~~~~~|");
System.out.println(" Wins: " + wins + "|Losses: " + losses);
System.out.println("|~~~~~~~~~~~~~~~~~~|");
}
//User wins
if(USER == ROCK)
if(PC == SCISSOR ){
System.out.println("You: Rock\nPC: Scissor");
System.out.println("Rock Breaks Scissor");
System.out.println("You Win! :]");
wins++;
System.out.println("|~~~~~~~~~~~~~~~~~~|");
System.out.println(" Wins: " + wins + "|Losses: " + losses);
System.out.println("|~~~~~~~~~~~~~~~~~~|");
}
//Pc wins
else if (PC == PAPER){
System.out.println("You: Rock\nPC: Paper");
System.out.println("Paper Covers Rock!");
System.out.println("PC Wins! >:D");
losses++;
System.out.println("|~~~~~~~~~~~~~~~~~~|");
System.out.println(" Wins: " + wins + "|Losses: " + losses);
System.out.println("|~~~~~~~~~~~~~~~~~~|");
}
//User Wins
if(USER == PAPER)
if(PC == ROCK){
System.out.println("You: Paper\nPC: Rock");
System.out.println("Paper Covers Rock");
System.out.println("You Win! :]");
wins++;
System.out.println("|~~~~~~~~~~~~~~~~~~|");
System.out.println(" Wins: " + wins + "|Losses: " + losses);
System.out.println("|~~~~~~~~~~~~~~~~~~|");
}
// Pc Wins
else if (PC == SCISSOR){
System.out.println("You: Paper\nPC: Scissor");
System.out.println("Scissor Cuts Paper!");
System.out.println("PC Wins! >:D");
losses++;
System.out.println("|~~~~~~~~~~~~~~~~~~|");
System.out.println(" Wins: " + wins + "|Losses: " + losses);
System.out.println("|~~~~~~~~~~~~~~~~~~|");
}
if(rnd==1){// I used .err so that in eclipse, the text would be red
System.err.println("\t\t\t\t\t" +
" Game Over!");
if(wins<losses){
System.err.println("\t\t\t\t\t YOU HAVE BEEN BEATEN BY THE PC!\n \t\t\t\t\t\t>:D");
}else if(wins>losses){
System.err.println("\t\t\t\t\t YOU BEAT THE COMPUTER!\n \t\t\t\t\t\t:]");
}else if(wins==losses){
System.err.println("\t\t\t\t\t STALEMATE!\n \t\t\t\t\t\t:\\");
}
}
}
}
}