-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1835 from ZapeeoSheikh/master
I have added java Program for rock paper scissors game
- Loading branch information
Showing
2 changed files
with
344 additions
and
0 deletions.
There are no files selected for viewing
145 changes: 145 additions & 0 deletions
145
Program's_Contributed_By_Contributors/Java_Programs/Data_structure/RockPaperScissor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
//Rock Paper Scissor Game | ||
|
||
package Rameez; | ||
|
||
import java.util.*; | ||
|
||
public class Main { | ||
|
||
public static void main(String[] args) { | ||
|
||
|
||
|
||
// public static void main(String[] args) { // Rock paper Scissor Game | ||
|
||
int victory = 0; | ||
|
||
|
||
|
||
int Rock = 0 , Paper = 1, Scissor = 2 ; | ||
|
||
int turn ; | ||
|
||
Scanner zap = new Scanner(System.in); | ||
|
||
Random ram = new Random(); | ||
|
||
System.out.println("This is a Rock- Paper-Scissor Game "); | ||
|
||
System.out.println(" Press Number Accordingly \n Rock --> 0\n Paper --> 1\n Scissor --> 2 \n "); | ||
|
||
System.out.println(" This Game has 5 Rounds "); | ||
|
||
for(int step = 1 ; step<= 5; step++){ | ||
|
||
System.out.println(" ******* Round 0" + step + " ********\n --> Computer's has Choosen the number\n "); | ||
|
||
int player1 = ram.nextInt(2); | ||
|
||
|
||
|
||
|
||
|
||
System.out.println(" --> Your's Turn "); | ||
|
||
int player2 = zap.nextInt(); | ||
|
||
|
||
|
||
while (player2 < 0 || player2 >= 3) | ||
|
||
{ | ||
|
||
System.out.println(" Please enter the number between 0-2 \n Enter the number again "); | ||
|
||
player2=zap.nextInt(); | ||
|
||
} | ||
|
||
if (player1==player2){ | ||
|
||
System.out.println(" Both choose same Weapon \n Match Tie !! "); | ||
|
||
} | ||
|
||
else | ||
|
||
{ | ||
|
||
if (player1==0 && player2 == 1){ | ||
|
||
|
||
|
||
System.out.println(" You wins !! "); | ||
|
||
victory+= 1; | ||
|
||
} | ||
|
||
else if (player1==1 && player2 == 0) | ||
|
||
{ | ||
|
||
System.out.println(" You loss !! "); | ||
|
||
System.out.println("Computer's Choice is " + player1 + " ( Paper )"); | ||
|
||
} | ||
|
||
|
||
|
||
else if (player1==2 && player2 == 1) | ||
|
||
{ | ||
|
||
System.out.println(" You loss !! "); | ||
|
||
System.out.println("Computer's Choice is " + player1 + " ( Scissor )"); | ||
|
||
} | ||
|
||
else if (player1==1 && player2 == 2){ | ||
|
||
System.out.println(" You wins !! "); | ||
|
||
victory+= 1; | ||
|
||
} | ||
|
||
else if (player1== 2 && player2 == 0){ | ||
|
||
|
||
|
||
System.out.println(" You wins !! "); | ||
|
||
victory+= 1; } | ||
|
||
|
||
|
||
else if (player1== 0 && player2 == 2) | ||
|
||
{ | ||
|
||
System.out.println(" You loss !! "); | ||
|
||
System.out.println("Computer's Choice is " + player1 + " ( Rock )"); | ||
|
||
} | ||
|
||
} | ||
|
||
System.out.println("\n__________________________\n"); | ||
|
||
if (step == 5 ){ | ||
|
||
System.out.println( " Your Total Victories are " + victory + | ||
|
||
" \n ******* Game End ******* " + "\n *** Programed By Muhammad Rameez ***\n ***** Gcu Lahore (0090-Bscs-20) *****"); | ||
|
||
|
||
|
||
}} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
<!DOCTYPE html> | ||
|
||
<html lang="en"> | ||
|
||
<head> | ||
|
||
<meta charset="UTF-8"> | ||
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
|
||
<title>Login Form</title> | ||
|
||
<link rel="preconnect" href="https://fonts.googleapis.com"> | ||
|
||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
|
||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@500&display=swap" rel="stylesheet"> | ||
|
||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.2.0/css/font-awesome-ie7.css"> | ||
|
||
<link href="https://fonts.googleapis.com/css2?family=Work+Sans:wght@200&display=swap" rel="stylesheet"> | ||
|
||
<style> | ||
|
||
.logo { | ||
|
||
color: white; | ||
|
||
font-size: 50px; | ||
|
||
} | ||
|
||
|
||
|
||
body { | ||
|
||
background-color: #589ED9; | ||
|
||
width: 200px; | ||
|
||
margin: 0 auto; | ||
|
||
} | ||
|
||
|
||
|
||
button { | ||
|
||
background-color: #1782DB; | ||
|
||
width: 100%; | ||
|
||
height: 40px; | ||
|
||
border: none; | ||
|
||
margin-top: 10px; | ||
|
||
border-radius: 3px; | ||
|
||
color: white; | ||
|
||
font-family: 'Open Sans', sans-serif; | ||
|
||
} | ||
|
||
|
||
|
||
.title { | ||
|
||
color: white; | ||
|
||
font-family: 'Open Sans', sans-serif; | ||
|
||
text-align: center; | ||
|
||
} | ||
|
||
|
||
|
||
.first { | ||
|
||
display: flex; | ||
|
||
justify-content: center; | ||
|
||
height: 50px; | ||
|
||
width: 200px; | ||
|
||
border-radius: 10px 10px 0px 0px; | ||
|
||
border: none; | ||
|
||
margin-bottom: 2px; | ||
|
||
text-indent: 20px; | ||
|
||
} | ||
|
||
|
||
|
||
.second { | ||
|
||
display: flex; | ||
|
||
justify-content: center; | ||
|
||
height: 50px; | ||
|
||
width: 200px; | ||
|
||
border-radius: 0px 0px 10px 10px; | ||
|
||
border: none; | ||
|
||
text-indent: 20px; | ||
|
||
} | ||
|
||
|
||
|
||
.header { | ||
|
||
margin-top: 150px; | ||
|
||
} | ||
|
||
|
||
|
||
a { | ||
|
||
color: white; | ||
|
||
font-family: 'Open Sans', sans-serif; | ||
|
||
text-decoration: none; | ||
|
||
} | ||
|
||
|
||
|
||
.footer p { | ||
|
||
color: white; | ||
|
||
font-family: 'Work Sans', sans-serif; | ||
|
||
font-weight: 300 | ||
|
||
} | ||
|
||
</style> | ||
|
||
</head> | ||
|
||
<body> | ||
|
||
<div class="header"> | ||
|
||
<div class="logo"> | ||
|
||
<i class="fa-brands fa-weibo"></i> | ||
|
||
</div> | ||
|
||
<div class="title"> | ||
|
||
<h1> Welcome. </h1> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
<div class="container"> | ||
|
||
<div class="field"> | ||
|
||
<input type="email" placeholder="Email" name="email" class="first" /> | ||
|
||
<input type="password" placeholder="Password" name="password" class="second" /> | ||
|
||
</div> | ||
|
||
<div class="button"><button type="submit" value="Login">Login</button> </div> | ||
|
||
</div> | ||
|
||
<div class="footer"> | ||
|
||
<p> <a href="#">Sign up</a> for a new account</p> | ||
|
||
</div> | ||
|
||
</body> | ||
|
||
</html> |