- Joined
- May 11, 2018
- Posts
- 3,638
- Solutions
- 5
- Reaction
- 5,772
- Points
- 1,612
Tama ka diyanHahahaha! Ano yan? Para sa grade mo? Pano naman yung grade namin?
//Created by PHC-BlackHatNBI
using System;
namespace PaperRockScissorsGame
{
class Program
{
static void Main(string[] args)
{
PaperRockScissorGame();
}
static void PaperRockScissorGame()
{
bool isGameOver = false;
string chosenLetter, generatedLetter, message;
int userScore = 0; int enemyScore = 0; int randomNumber = 0;
Random random = new Random();
do
{
randomNumber = random.Next(1, 4);
Console.WriteLine("Your score {0} || Enemy's score {1}", userScore, enemyScore);
Console.WriteLine("Pick your weapon!");
Console.WriteLine("P: Paper");
Console.WriteLine("R: Rock");
Console.WriteLine("S: Scissors");
chosenLetter = Console.ReadLine();
if (randomNumber == 1)
{
generatedLetter = "P";
}
else if (randomNumber == 2)
{
generatedLetter = "R";
}
else
{
generatedLetter = "S";
}
if (chosenLetter.ToUpper() == "P")
{
if (generatedLetter == "P")
{
message = "Both of you have chosen paper. Pick again!";
}
else if (generatedLetter == "R")
{
message = "You have defeated the enemy's rock!";
userScore++;
}
else
{
message = "Enemy's scissors have destroyed your paper!";
enemyScore++;
}
}
else if (chosenLetter.ToUpper() == "R")
{
if (generatedLetter == "P")
{
message = "Enemy's paper has swollowed your rock!";
enemyScore++;
}
else if (generatedLetter == "R")
{
message = "Both of you have chosen rock. Pick again!";
}
else
{
message = "You have defeated the enemy's scissors!";
userScore++;
}
}
else if (chosenLetter.ToUpper() == "S")
{
if (generatedLetter == "P")
{
message = "You have defeated the enemy's paper!";
userScore++;
}
else if (generatedLetter == "R")
{
message = "Enemy's rock has destroyed your scissors!";
enemyScore++;
}
else
{
message = "Both of you have chosen scissors. Pick again!";
}
}
else
{
message = "Please choose valid letters only.";
}
Console.WriteLine(message);
if (userScore == 5 || enemyScore == 5)
{
Console.WriteLine("Game over. Your score: {0} || Enemy's Score: {1}", userScore, enemyScore);
isGameOver = true;
}
}
while (!isGameOver);
}
}
}
Maraming salamat paps kaso kailangan raw paps 2 player at tsaka java scanner lng raw gamitin pero salamat parin paps sa effort moAnonyman ginawa ko yung number 1 problem mo using C#.
Pwede mong i-run yung console app na ginawa ko by clicking You do not have permission to view the full content of this post. Log in or register now..
Assuming na may programming knowledge ka na, please aralin mong mabuti kung paano ko siya cinode at magtanong ka lang kung may gusto kang linawin
C#://Created by PHC-BlackHatNBI using System; namespace PaperRockScissorsGame { class Program { static void Main(string[] args) { PaperRockScissorGame(); } static void PaperRockScissorGame() { bool isGameOver = false; string chosenLetter, generatedLetter, message; int userScore = 0; int enemyScore = 0; int randomNumber = 0; Random random = new Random(); do { randomNumber = random.Next(1, 4); Console.WriteLine("Your score {0} || Enemy's score {1}", userScore, enemyScore); Console.WriteLine("Pick your weapon!"); Console.WriteLine("P: Paper"); Console.WriteLine("R: Rock"); Console.WriteLine("S: Scissors"); chosenLetter = Console.ReadLine(); if (randomNumber == 1) { generatedLetter = "P"; } else if (randomNumber == 2) { generatedLetter = "R"; } else { generatedLetter = "S"; } if (chosenLetter.ToUpper() == "P") { if (generatedLetter == "P") { message = "Both of you have chosen paper. Pick again!"; } else if (generatedLetter == "R") { message = "You have defeated the enemy's rock!"; userScore++; } else { message = "Enemy's scissors have destroyed your paper!"; enemyScore++; } } else if (chosenLetter.ToUpper() == "R") { if (generatedLetter == "P") { message = "Enemy's paper has swollowed your rock!"; enemyScore++; } else if (generatedLetter == "R") { message = "Both of you have chosen rock. Pick again!"; } else { message = "You have defeated the enemy's scissors!"; userScore++; } } else if (chosenLetter.ToUpper() == "S") { if (generatedLetter == "P") { message = "You have defeated the enemy's paper!"; userScore++; } else if (generatedLetter == "R") { message = "Enemy's rock has destroyed your scissors!"; enemyScore++; } else { message = "Both of you have chosen scissors. Pick again!"; } } else { message = "Please choose valid letters only."; } Console.WriteLine(message); if (userScore == 5 || enemyScore == 5) { Console.WriteLine("Game over. Your score: {0} || Enemy's Score: {1}", userScore, enemyScore); isGameOver = true; } } while (!isGameOver); } } }
Java using scanneranong programming language?
May challenge din ako sayo TS. Gawa mo ng program tapos ipost mo dito.
May challenge din ako sayo TS. Gawa mo ng program tapos ipost mo dito.
public void main()
{
1. Get input of player 1 - R, P, S
2. Get input of player 2 or random - R, P, S
if(input1 == input2)
{
//Draw
}
else
{
if(input1 is S and input2 is R
or input1 is R and input2 is P
or input1 is P and input2 is S)
{
//Lose
//Add point to player 2
}
else
{
//win
//Add point to player 1
}
}
if(scorePlayer1 == 5)
{
//You win
//End
}
else if (scorePlayer2 == 5)
{
//You lose
//End
}
Repeat (While)
}
Gusto ko sana sagutin yan kahit sa isang thread niya kaso tagal ko na hindi nag java need ko pa aralin syntax, masasagot ko yan sa javascript at html. Anyway meron na nakasagot at nagbigay ng ideas.
Sad naman sige sorryGusto ko sana sagutin yan kahit sa isang thread niya kaso tagal ko na hindi nag java need ko pa aralin syntax, masasagot ko yan sa javascript at html. Anyway meron na nakasagot at nagbigay ng ideas.
No need to say sorry hehe.Sad naman sige sorry
paano Yan papsCode:public void main() { 1. Get input of player 1 - R, P, S 2. Get input of player 2 or random - R, P, S if(input1 == input2) { //Draw } else { if(input1 is S and input2 is R or input1 is R and input2 is P or input1 is P and input2 is S) { //Lose //Add point to player 2 } else { //win //Add point to player 1 } } if(scorePlayer1 == 5) { //You win //End } else if (scorePlayer2 == 5) { //You lose //End } Repeat (While) }
Yan yung short idea. Wag maraming if else.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?