Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace APp
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private int draws;
- private int wins;
- private int losses;
- bool Paper;
- bool Rock;
- bool Scissor;
- Random rand = new Random();
- //case statement maken of while loop
- //methode met een return waarde
- //list en array
- private void GameCheck(bool Paper, bool Rock, bool Scissor)
- {
- if (radioButtonPaper.Checked)
- {
- if (Paper == true)
- {
- listBox1.Items.Add("Paper vs Paper - Draw");
- draws += 1;
- }
- else if (Rock == true)
- {
- listBox1.Items.Add("Paper vs Rock - Win");
- wins += 1;
- }
- else
- {
- listBox1.Items.Add("Paper vs Scissor - Loss");
- losses += 1;
- }
- }
- else if (radioButtonRock.Checked)
- {
- if (Paper == true)
- {
- listBox1.Items.Add("Rock vs Paper - Loss");
- losses += 1;
- }
- else if (Rock == true)
- {
- listBox1.Items.Add("Rock vs Rock - Draw");
- draws += 1;
- }
- else
- {
- listBox1.Items.Add("Rock vs Scissor - Win");
- wins += 1;
- }
- }
- else if (radioButtonScissor.Checked)
- {
- if (Paper == true)
- {
- listBox1.Items.Add("Scissor vs Paper - Win");
- wins += 1;
- }
- else if (Rock == true)
- {
- listBox1.Items.Add("Scissor vs Rock - Loss");
- losses += 1;
- }
- else
- {
- listBox1.Items.Add("Scissor vs Scissor - Draw");
- draws += 1;
- }
- }
- }
- enum Moves
- {
- Paper = 1,
- Rock = 2,
- Scissor = 3
- }
- void EnemySelect()
- {
- //Array
- Array values = Enum.GetValues(typeof(Moves));
- Moves randomMove = (Moves)values.GetValue(rand.Next(values.Length));
- if (randomMove == Moves.Paper)
- {
- Paper = true;
- Rock = false;
- Scissor = false;
- }
- else if (randomMove == Moves.Rock)
- {
- Paper = false;
- Rock = true;
- Scissor = false;
- }
- else
- {
- Paper = false;
- Rock = false;
- Scissor = true;
- }
- }
- void statUpdate()
- {
- Wins.Text = "Number of wins: " + wins;
- Draws.Text = "Number of draws: " + draws;
- Losses.Text = "Number of losses" + losses;
- }
- int count()
- {
- int totalPlays = wins + draws + losses;
- return totalPlays;
- }
- private void ButtonPlay_Click(object sender, EventArgs e)
- {
- {
- //Loops
- if (numericUpDown1.Value != 0)
- {
- //for (int i = 0; i < numericUpDown1.Value; i++)
- //{
- // EnemySelect();
- // GameCheck(Paper, Rock, Scissor);
- // statUpdate();
- //}
- int i = 0;
- while (i < numericUpDown1.Value)
- {
- EnemySelect();
- GameCheck(Paper, Rock, Scissor);
- statUpdate();
- i++;
- }
- MessageBox.Show("total played = " + count());
- }
- else
- {
- EnemySelect();
- GameCheck(Paper, Rock, Scissor);
- statUpdate();
- MessageBox.Show("total played = " + count());
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement