Advertisement
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;
- namespace Dice {
- /// <summary>
- /// Represents one die (singular of dice) with faces showing values between
- /// 1 and the number of faces on the die.
- /// </summary>
- public class Die {
- private int faces;
- private int value;
- // Implement your 'Die' class here
- public Die(int faces = 6) {
- if (faces < 3) {
- this.faces = 6;
- }
- else {
- this.faces = faces;
- }
- }
- public void RollDie() {
- Random rand = new Random();
- value = rand.Next(1, faces + 1);
- }
- public int GetFaceValue() {
- return value;
- }
- public int GetNumFaces() {
- return faces;
- }
- }// end Class Die
- public class Program {
- public static void Main() {
- // This will not be called by the AMS, however you may want to test your Die class here.
- Die myDie = new Die();
- for (int n = 1; n <= 1000; n++) {
- myDie.RollDie();
- Console.WriteLine(myDie.GetFaceValue());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement