Skip to main content

Posts

Showing posts with the label random

Two random number generators (card dealing)

I need help with this part of my code. This part deals with generating 2 random numbers and using that random number to display a card in each of 2 label boxes simultaneously. The problem here is the random numbers are not getting generated properly and thus cards are not displayed properly (there is repetition, sometimes no display, etc) Basics of my code: Let us assume h, which is a variable from another part of the code, is any number between 1 and 53 (each number pertaining to a card). If the random number generated (non-repetition) matches the variable h the timer stops. So its basically like having a deck of cards and dealing out the cards evenly to 2 people, but here the dealing stops once a number pertaining to a card (number) randomly taken is matched. (l3,l4 are label names) Global variables: Random rng = new Random(); List<Integer> generated = new ArrayList<Integer>(); List<Integer> generated2 = new ArrayList<Integer>(); int l3coun

monkey runner random generation

When I want to input some character I do it like this device.press("0",MonkeyDevice.DOWN_AND_UP) this makes input of char '0', and it works great but the problem is I want to enter random numbers between 0 and 9 for let say 1000 times how can I do this ? how can I play with random generation in monkeyrunner I want randomly to choose between: device.press("0",MonkeyDevice.DOWN_AND_UP) device.press("1",MonkeyDevice.DOWN_AND_UP) device.press("2",MonkeyDevice.DOWN_AND_UP) device.press("3",MonkeyDevice.DOWN_AND_UP) ... device.press("9",MonkeyDevice.DOWN_AND_UP) EDIT I want to do this device.press("Random Number between zero and nine",MonkeyDevice.DOWN_AND_UP) device.press("Random Number between zero and nine",MonkeyDevice.DOWN_AND_UP) device.press("Random Number between zero and nine",MonkeyDevice.DOWN_AND_UP) device.press("Random Number between zero and nine",MonkeyDevi