Java Implement Slotmachine Class According Uml Diagram Look Slides Book Don T Remember Re Q43894673
[Java]
Implement the SlotMachine class according to the UML diagrambelow. Have a look at the slides or the book if you don ’ tremember how to read the UML. Underlined fields or methods in aUML, specify that they are static. The two fields numPlayerWins andnumHou seWins are both static and act as counters to keep track ofwins
+ numPlayerWins : int
+ numHouseWins : int
-reels : int[][]
-gambleMachine(): void
+ isWinner(): boolean
+ SlotMachine()
The method gambleMachine will populate reels , which is a 3x3array. Populate the array using the random number generator . Usenumbers in the range between 1 and 9, including 9. The methodisWinner will check if any of the three rows have the same values,it will also check if the one of the two diagonals has the samevalues. If any of the rows or the diagonals have the same numbers,it will return true , otherwise it will return false . The non -default constructor just calls the method gambleMachine..
The Casino class will just have the main method . In the mainmethod create an array of type SlotMachine of size 1,000,000. Usinga for – loop create objects of type SlotMachine and populate thearray.Inside of the same for – loop
check if the slot is a winner, if it is than increment the fieldnumPlayerWins . If the slot is not a winner than increment thefield numHouseWins . As you c reate objects of type SlotMachine theinvoked constructor will call the method gambleMachineautomatically, all you have to do is call the method isWinner oneach object. After the for loop print out the number of times thecasino has won and the number of times that the player has won.Also calculate and print out the chance of the player winningoverall ( numbersWon/totalNumbersPlayed). Keep in mind,staticfields can be calleddirectly on the class name (SlotMachine) . Allof the instances of SlotMachine will share the same values for thefields numPlayerWins and numHouseWin.This is because they arestatic, and they belong to the clas s and not any specific instanceof that class.
Expert Answer
Answer to [Java] Implement the SlotMachine class according to the UML diagram below. Have a look at the slides or the book if you …
OR