Path: csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!feeder2.ecngs.de!ecngs!feeder.ecngs.de!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 25 Feb 2013 05:10:51 -0600 Date: Mon, 25 Feb 2013 11:10:49 +0000 From: lipska the kat <"nospam at neversurrender dot co dot uk"> Organization: Trollbusters 3 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120410 Thunderbird/11.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: BlueJ don't know what i did wrong References: <638ed624-9eba-44eb-bcbf-68466e5bb5f1@googlegroups.com> <42d76fca-d365-4030-ae8c-07a806eab87c@googlegroups.com> <1wtai7dd80h80$.6rbtwoyou3gh.dlg@40tude.net> <5q6dnc3pF_HJzLfMnZ2dnUVZ7s-dnZ2d@bt.com> <77afaabf-ec0f-46d6-b3ea-d8f186dbf7e4@googlegroups.com> In-Reply-To: <77afaabf-ec0f-46d6-b3ea-d8f186dbf7e4@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: Lines: 51 X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-VhtGsYKNmu58Ok6CUHMdSgNbAHn0Bt2m2vpujyMCv3qJTVbRlwPSx9q0e6oKm87RVEWrq50NF2NCld/!9N16WezJJN61pBEPmbkpvN4QMYkVyfgUvXIL3fnyReoDCqtYrt51PzX5o7sgkNH2dqYfVoU/N/8= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3304 Xref: csiph.com comp.lang.java.programmer:22501 On 25/02/13 09:52, marvin.radke@htp-tel.de wrote: > sorry for the late answer :/ > > well.. the game is like said a tabletop game with many units which are grouped on cards. And this cards i want to give to the players, 3 cards are 2 times available thats why i did it like this.... > > I have done the same with the programm "turbo pascal" and there its working (just some changes), but wanted to write it so that it works with BlueJ. BlueJ is an IDE, it's not a problem with BlueJ it's a problem with your Java code, the problem might occcur regardless of IDE, it occurs when I run the code in Eclipse, another Java IDE, it would also randomly occur if you run your code from a terminal prompt. > The way i wanted it to work is that it choose randomly a card, Do you know what a stack is ? A stack is a simple LIFO (Last In First Out) data structure, in fact it's much like a deck of cards. If you push all your cards onto a stack in a random order then you can simply pop them off when you need them. When the deck (stack) is empty all the cards are dealt out and (presumably) your game can commence. Java has a built in Stack data structure, you can find out about it here http://docs.oracle.com/javase/6/docs/api/java/util/Stack.html Stack s = new Stack() //populate the stack for(...){ stack.push(someObject) } ... get a 'card' SomeObject = stack.pop(); This would avoid using the result of getting a value from the array as a test for your if/for/while conditionals It might be worth a try lipska -- Lipska the KatŠ: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun