java - How to make a Loaded Dice -
I am creating a square of this dice squared called loaded dice which will load a dice roll and a certain percentage
'Got some signals to create an In addition to this, all the dice squares are coming from the dying class created by me. I can also provide it if necessary. aristlist
and made it more than a number and made another and there Area is selected randomly, but it may be a cleaner way? > Public squares dice {/ /---------------------------------- - ------- // instance variables // ----------------------------------- - - - Private Arrestist & Lt; Die & gt; DieArray; // ------------------------------------------------ // Constructor // --------------------------------------------- - / ** * Default Constructor 2 6 Sided Dice * / Public Dice (Diareare = New Arrayist & # 39; Die & gt; (); DieArray.add (new die); DieArray.add (new die) );} / ** * Use an array list * / Public Dice (Arrelist Lieutenant; Dy> Some Dicks) of Direct Objects {dieArray.addAll (someDice);} / ** * 1 int #), Which is a 6-party * Dice * / Public Dice (Int. NumericOfidies) creates the number of {dieArray = new ArrayList & lt; Die & gt; (); for (int i = 0; i & lt; numberofdice; i ++) {dieArray.add (new die)); }} / ** * takes in 2 inches (# of die #, dies per #), which * number of pipes * per number of direct sides * / public dice (int number, int numofysaid) {DieArray = new ArrayList & lt; to die & gt; (); for (int i = 0; i & lt; numberofdice; i ++) {dieArray.add (new die (side off side)); }} // ---------------------------------------------- --- Class Classes Methods ----------------------------------------- -------- / ** * Includes: 0 parameter, and returns a string value * representing all dice * / public string containers () {string dieString = new string (); For (int i = 0; i & lt; dieArray.size (); i ++) {dieString + = (dieArray.get (i) + ""); } Return dieString; } / ** * Roll: 0 takes the criteria, and returns an integer value which is the sum of all the dice * * / public int roll () {int value = 0; (Int i = 0; i & lt; dieArray.size (); i ++) for {value = value + dieArray.get (i) .roll (); } return value; } / ** * Add: takes a die object as an input parameter and adds it to the * current Dice * / Public Wide (insert new) {dieArray.add (newDie); }}
Comments
Post a Comment