Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Cube2
- {
- class Program
- {
- static void Main(string[] args)
- {
- Player Danny=new Player();
- Player Moshe=new Player();
- bool doub = false;
- while (Danny.Win() != true && Moshe.Win() != true)
- {
- doub = Danny.Roll(doub);
- Console.WriteLine("Danny's sum is " + Danny.getPoints());
- doub = Moshe.Roll(doub);
- Console.WriteLine("Moshe's sum is " + Moshe.getPoints());
- }
- if (Danny.Win() == true && Moshe.Win() == true)
- Console.WriteLine("Tie");
- else if (Danny.Win() == true && Moshe.Win() == false)
- Console.WriteLine("Danny won");
- else Console.WriteLine("Moshe won");
- }
- }
- class Player
- {
- private int points;
- public Player()
- {
- points = 0;
- }
- public bool Roll(bool doublePoints) // מציבים האם השחקן הקודם קיבל דאבל
- {
- Random rand = new Random();
- int R1 = rand.Next(1, 7);
- rand = new Random(points++); // points++ כדי שהראנדום ישתנה כל הטלת קובייה
- int R2 = rand.Next(1, 7);
- if (doublePoints == true) // אם לשחקן הקודם היה דאבל, אז השחקן עכשיו יקבל פי 2 ניקוד
- points = points + 2 * (R1 + R2);
- else
- points = points + R1 + R2;
- return (R1 == R2); // אם השחקן עכשיו קיבל דאבל, אז זה מחזיר אמת
- }
- public int getPoints()
- {
- return points;
- }
- public bool Win()
- {
- if (points >= 100)
- return true;
- else return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment