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ɏ츯c'Q&gduG!a3eίo6r6XvCP3L OghѬctQ5]@lj׹:+{ԽQLu߭+UrF:tOh4?Ir Fy{a" } ^%Y)1>x2nN><t'߹iOUN2qZ%n{yc4=;"??OgWWټi3{E|쉝vo.8q=T?v4Ǭ/-Eȋr}:vbɭ5&wGj.ğc^poO<Ǜq&˕q75ywXBxAEk2 IHuNTgY\=5%鑪GCmhoFr%)U6Wܯi k'^/QtVo~Nn샥ߑߓvAɟ&x:?9G&>s샥{90; }~Ni{"?~L :?>s4gtc'=Cd~÷<</bE#kȶI]{)ؚzkzeE.t)FB׹uWV^y:)kewZcaw)`4iE-GDe2~"ݿy-|!k;ce_k;3:f'&93>~|LEhgŝ?_;zoϥc}㚨߱qt9Dw+~ċ|z6֊OWױpEUcxѢpFWdl (  / 0|DTimes New Roman@b@bLb0pbpb 0DArial Blackman@b@bLb0pbpb 0" DTahomalackman@b@bLb0pbpb 0"0DMonotype Sorts@b@bLb0pbpb 0@DArialpe Sorts@b@bLb0pbpb 0"  @n?" dd@  @@`` D</E        /X$zR$bؙ iԌV g?zc $ @8> g4AdAd|b 0tbV (ppp@ <4!d!d@b\ g4KdKd|b 0tbZ p@ pp?T+ @Tim Margush, University of AkronOl;ST: Java @Tim Margush, University of AkronAroma 2: The Die ClassSpecial Topics: Java Dice RollingA Die commonly has 6 faces Faces are numbered 1 through 6 When rolled, each face is equally likely to appear on top (a fair Die) We want to simulate a fair Die with an arbitrary number of faces We will number the faces 1 through nH%%java.util.Random$class Random Used to create Random objects Each Random object is able to produce a stream of pseudorandom numbers Seed? new Random() vs new Random(x) Methods: nextInt(), nextLong(), etc.H k% k%b]  A Class to Die ForDie Constructor, Die!Roll Die! Roll!Die Test Class/ !"#  ` ^WN̙f` ^WNff3` 999MMM` ^WNf` ff33` ff33` ^WN̙f>?" dd@(?zdd@ y x@" `  n?" dd@   @@``@n?" dd@  @@``PR   @ ` ` p>> ^V(    C XA@C:\WINDOWS\DESKTOP\JavaBack.jpg  s *Dt 0` v T Click to edit Master title style! !   c $t @ v RClick to edit Master text styles Second level Third level Fourth level Fifth level!     S  s *u Tt v E* 2  s *du Tt   G*(2  s *u T@t  JA2-*(2Z  B޽h))? ? ^WNff3 Javaxx.potd   ` ( &`    C XA@C:\WINDOWS\DESKTOP\JavaBack.jpg  s * @@  T Click to edit Master title style! !  c $t @   W#Click to edit Master subtitle style$ $  s *Զ T  E* 2^WN  s *4 T   G*(2^WN  s * T@  G*(2^WNZ  B޽h))? ? ^WNff3 0 @.(    0 P    Y*   0t     [* d  c $ ?    0Գ  @  RClick to edit Master text styles Second level Third level Fourth level Fifth level!     S  64 `P  v Y*   6 `   [* H  0޽h ? ̙33 04(      0 P    =*   0     ?*   6T `P   =*   6 `   ?* H  0޽h ? ̙33 xP( K l  C  PP   r  S T ` p    00 pj VDr. Tim Margush Department of Mathematics and Computer Science The University of AkronW(2WH  0޽h ? ^WNff3  p(  l  C t0`   l  C @  H  0޽h ? ^WNff3  ( )pM@ l  C 0`   l  C @  H  0޽h ? ^WNff3  |[( )pM@ |l | C ԛ0`    | C 4@  Oimport java.util.Random; public class Die{ static private long nextSeed = new Random().nextLong(); private int sides; private Random theDie; ... }t2 H | 0޽h ? ^WNff3  Y(  l  C 0`     C T@  M Die(int sides){ if (sides<1) sides=6; this.sides=sides; theDie=new Random(nextSeed); nextSeed=theDie.nextLong(); }tH   H  0޽h ? ^WNff3   7(  l  C ԰0`     C 4@  +k public int roll(){ int rand = Math.abs(theDie.nextInt()) return rand % sides + 1; }ll H  0޽h ? ^WNff3P  h(  hl h C 0`    h C @  import Die; public class DieTest{ public static void main(String args[]){ Die d1 = new Die(6); Die d2 = new Die(6); for (int i=1; i++<20; ) System.out.println("d1 " +d1.roll()+" d2:"+d2.roll()); } }P$L$0H h 0޽h ? ^WNff3 0 C;(  R  3    A  C D2 @   The Die class is used to instantiate a single Die with an arbitrary number of faces. Once constructed, each Die object can be rolled to select (randomly) one of the faces. H  0޽h ? ̙33 0 \T( 8t@m@ R  3    Z  C 1 @   |Java provides a randon number generator (pseudorandom) called Random. This class is in the package named java.util. It is used to construct Random objects, each capable of generating a sequence of random numbers using a pseudorandom number generator. The constructor allows you to specify the initial seed for the generator if you wish. If not specified, the current time is used.b 3j H  0޽h ? ̙33 0 C( d2w0z R  3      C $1 @   QHere we see the beginning of the class definition. A class variable is created and initialized with a random long integer obtained from a new Random object. This new object is instantiated with the default constructor, so the current time is used to seed its generator. This object stays around just long enough to generate one random number. Garbage collection will get it later. The instance variables sides and theDie will hold the state of each Die object as it is instantiated. Note that each Die gets its own random number generator.wH  0޽h ? ̙33 0 ((   R  3      C 0 @   6The constructor verifies a legal number of sides, then instantiates a new Random object using the class variable nextSeed as the seed. It then changes the class variable to another random number, taken from the Random object just created.,7 - uH  0޽h ? ̙33 0 ia(   R  3    g  C d0 @   The roll method simply gets a random int from the Random object (instance variable theDie) and wraps it into the proper range of face values. The absolute value function is used to ensure a positive result from the mod operation. The Math class is part of the java.lang package and is automatically imported. The Math class has a class method, abs, that returns the absolute value of a number.b%*J/H  0޽h ? ̙33 0 x( |@@I@ R  3    ~  C * @    H  0޽h ? ̙33 0  =( x~0 R  3    v  C * @  v K7This is a simple class used to test the Die class. Two Dice are instantiated, each with 6 sides. Twenty rolls are taken and the results of each roll are displayed. Note the import statement that declares the Die class to be used in this test. Classes are often tested using simple "driver" classes such as this.H  0޽h ? ̙33rT`! h%q5.,Q/r2n(N*8T;>BEILKpAN#(0Oh+'0tRxP dp   Aroma 2: The Die ClassA sample class implementaiont Tim Margush,Class notes for 3460:289 ST:Java, Fall 19987C:\Program Files\Microsoft Office\Templates\Javaxx.pot Tim Margush3m Microsoft PowerPointoso@ ˜ @X;ؽ@'z.۽+GPoM  P('& &&#TNPPp0D v & TNPP &&TNPP     'A x(xʦ """)))UUUMMMBBB999|PP3f3333f333ff3fffff3f3f̙f3333f3333333333f3333333f3f33ff3f3f3f3333f3333333f3̙33333f333ff3ffffff3f33f3ff3f3f3ffff3fffffffff3fffffff3f̙ffff3ff333f3ff33fff33f3ff̙3f3f3333f333ff3fffff̙̙3̙f̙̙̙3f̙3f3f3333f333ff3fffff3f3f̙3ffffffffff!___wwwݼݽݼݽ޼ݽݼݼݼݼݼݽ޼ݼݼݽ޼ݼݼݼݽñݼݼݼݼݼݼݼݼݼݼݼݼݼݼݼݽݼݽݽݼ޼ݼݽݽݼݼݼݼݼ޼ݼݼݼݼݼݼ޼ݽݼݽ޽ݽݼݽݽݽݼ޼ݼñݼݽޔtttu㓱ݽݼ޼oݼݽݽýý޽ݼݼݽݽݼݼݼݼݼ޼ݼݼݼݼ޼ݼݼݽ޼ݼݽݼݼ޼ݼݽݼݼݽݼݽݽݼݼݼݼݽݽݽݼݼݼݼݼݽý޼ݼݽݽݽ޼޼ޔoݼݼݽݽݽݼݼݽݽݼݽݽݼݽݼ޼޽ݼݼݽ½޼ݽݽ޽޼ݼݼݽݼ޼⽽ݽݼݽ޽ݽ޽ݽݽݔݼݼݽݽ޽ݽݼ޽ݽݽݽ޽ݽݼ½ݼ޼ݽ޼ݽݽݼݼݽݼݼ޼ݼݼݼݼ޼ݼݽݼݽݼݼݼݽݼݼݼݼݼ޼ݼ㔼ݽݼݼ޼ݼݼݽݽݼ޼ݼݼݽݽ޼ݼݽ޼ݼ޼޼޼ݼݼݼݽ޽޽ݼݼݼݼݼ㓔ݼ޼ݼݼݼݽݽݽݼݼݽݼݼݼݼݼ޽ݼݼޔݽݽݽݽݼݼݼݼݽݼ޽޽޽޽½޽޽޽޽޽޽ýýý޽޽޽޽޽ý޽޽޽޽޽޽޽޽޽޽޽⽽޽޽޽޼޽޽޽ý޼޼޽ý޽ýý޶޽޽޽޽޽޼޽ýýt㔶޽޽ݽ޽޽t޽u޽ý޽޽޽޽޽޽㱓޽񽽽޽޽޽޽޽޽޽޽޽ýݽ޽޽޽޽⼼޽ý޽޽޽ýnmJJ޽޽m##D##DsݼýÒD)D###$##JD#$#$###"#Dn޽D$#*#*#$##"nJ"D޽޽ýn)$#$#$#*$$Ds޽#$#*#*$)D#)$#޽s#$$#D##CDCE)$JQ0s޽񽽽޽ݽ#$D7)ý񽽽ý)#f7_D޽޽#DrDJtKn޽ݽ޽CsmLuMMtý"#JJLRR޽޽nDnELMMSMDg##m޽޽ֻ#"`Csޘ޽֧ȧ޽޶޽޽㓽޽޽o÷ "--&TNPP &՜.+,D՜.+,x     On-screen ShowUniversity of Akron(<  Times New Roman Arial BlackTahomaMonotype SortsArial Javaxx.potAroma 2: The Die Class Dice Rollingjava.util.RandomA Class to Die ForDie Constructor, Die!Roll Die! Roll!Die Test Class  Fonts UsedDesign Template Slide Titles$em  5    _PID_GUID TemplateType GraphicType Compression ScreenSize ScreenUsage MailAddress HomePage Other DownloadOriginal DownloadIEButton UseBrowserColor BackColor TextColor LinkColor VisitedColorTransparentButton ButtonType ShowNotes NavBtnPos OutputDirAN{E4E05680-4757-11D2-9E0C-00403331078B}Fmargush@uakron.edu"http://www.cs.uakron.edu/~margushvjClass Notes for ST:Java Tim Margush Department of Mathematics and Computer Science University of Akronm   f3 C:\WINDOWS\DESKTOP\Java#_N bTim Margush !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqstuvwxy{|}~Root EntrydO)Picturesg?Current UserzSummaryInformation(HRPowerPoint Document( NDocumentSummaryInformation8r