This has nothing to do with Android. You are not requesting a random
number when i==0.

On Fri, Mar 23, 2012 at 10:48 AM, Kristoffer <[email protected]> wrote:
> Hello.
>
> Iam having a problem with the Random()
>
> everything gets random except for cards[0][0] that always ends up with
> = 5
>
> here is the code that i use, anyone have a solution?
> in the code ROW_COUNT = 3 and COL_COUNT = 4
>
> private void loadCards(){
>                try{
>                int size = ROW_COUNT*COL_COUNT;
>
>                ArrayList<Integer> list = new ArrayList<Integer>();
>
>                for(int i=0;i<size;i++){
>                        list.add(new Integer(i));
>                }
>
>                Random r = new Random();
>
>                for(int i=size-1;i>=0;i--){
>                        int t=0;
>
>                        if(i>0){
>                                t = r.nextInt(i);
>                        }
>
>                        t=list.remove(t).intValue();
>                        cards[i%COL_COUNT][i/COL_COUNT]=t%(size/2);
>                }
>            }
>                catch (Exception e) {
>                        Log.e("loadCards()", e+"");
>                }
>
>    }
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 4.1 Available!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to