1. Check out our companion app, Forums for Android! Download from Google Play

Push button application

Discussion in 'Application Development' started by OberSchutze, Jan 4, 2013.

  1. OberSchutze

    OberSchutze Member
    Thread Starter
    36

    Jul 19, 2012
    14
    1
    36
    Hello, I am trying to figure out how to implement a small project. I have the control logic figured out I am just new to android development to have a full handle on the task at hand.

    I have essentially a 5x4 matrix of buttons that I want to at random light up in a randomized time between 6 and 30 seconds between light up.. The person needs to push the button back in to reset it before 5 seconds or a small red X appears over the button. If the person misses more than 3 times the screen flashes red for a second before resetting the red Xs and the count starts over. There is also a reset button that will reset the counts and start over again and a exit button that will bring up a results page that has how many hits and misses and elapsed time. It should also create a small graph that shows the % correct over time.

    Any help will be greatly appreciated.
     

    Advertisement

  2. OberSchutze

    OberSchutze Member
    Thread Starter
    36

    Jul 19, 2012
    14
    1
    36
    Anyone have any ideas? I am still fairly new to software development.
     
  3. OberSchutze

    OberSchutze Member
    Thread Starter
    36

    Jul 19, 2012
    14
    1
    36
    Well I figured out the XML part and that is mostly working. Having some small troubles with custom buttons but I can deal with that later. This question revolves around using the java math random function.

    I am trying to create two discrete random events, however from what I understand about the random function I have to use an initial seed value of say 5. If my range is 1 to 24 I do not want to have 5 be the first value every time I start the application.

    So my question is, can I make say 3 random functions that trigger after each other and use those values as my initial seed value in the random number I want for the first event to trigger?

    For example:

    Random #1 has a seed value of 5.

    Once that triggers the number that is output is the seed variable of Random #2.

    Then Random #3 uses the value generated from Random #2 as its seed value to get me a actual random number.

    Does that make sense or am I overly complicating it?

    Here is some code to hopefully help:
    [HIGH]
    public class randomgen{
    public static void main(String[] args){
    Random rand = new Random();
    int num1 = rand.nextInt(24);
    System.out.println("Generated Random Number between 0 to 24 is : " + num1);
    int num2 = rand.nextInt(num1);
    System.out.println("Generated Random Number from seed 1 is : " + num2);
    int num3 = rand.nextInt(num2);
    System.out.println("Generated Random Number from seed 2 is : " + num3);
    }
    }
    [/HIGH]
     

Share This Page

Loading...