🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #2594

How to create a loop in java?

#2594
From: Rolf Schellenberger
Date: Thu, 21 Sep 2000 00:00
65 lines
2778 bytes
Help with a loop
I want to create a loop in my source, but I can't get it to work. What's

the problem?
This is my source:

Classfile: creates random digit between 1 and 10.

Sourcefile: must place two digits in two textFields. (digitField1 and
digitField2). I want the random created digits NOT to be the same, so I
want to let the program compare the two digits and IF they are the same,

than create a new random digit for digitField2. The program is must have

a loop to create a new random digit for digitField2 if digitField1 and
digitField2 have the same digit.
The problem is: I don't know how to create this loop. Can someone help
me?

This is the sourcefile (not the classfile):

DraaikubusRandom field1 = new DraaikubusRandom();
DraaikubusRandom field2 = new DraaikubusRandom();

void opnieuwButton_Action(java.awt.event.ActionEvent event)
 {
  //Creation random digit
  //Digit 1
Digit1: //Label Digit1
  field1.create();
  digitField1.setText(String.valueOf(field1.getAmount()));

  String correct1 = digitField1.getText();
  int icorrect1 = Integer.parseInt(correct1);

  //Digit 2
Digit2:     //Label Digit2
  field2.create();     //Create random digit
  digitField2.setText(String.valueOf(field2.getAmount()));     //Place
the random digit in digitField2

  String correct2 = digitField2.getText();
  int icorrect2 = Integer.parseInt(correct2);     //Get the digit from
field2

  if (icorrect1 == icorrect2)    //Compare booth digits
  {
      continue Digit2;     //If they are the same, I want the program to

create a new random digit and to do that it needs to go to the label for

Digit2.
  }
  else     //If they are not the same, just continue.
  {}

If someone could help me with this problem, because this doens't
work.The program says "no label defenition found for Digit2".
If you could correct my source, give me a new source or if you could
send me a default source for a loop, that would be great.

Thanks,
Rolf Schellenberger,
The Netherlands.
b.schellenberg@inter.nl.net
Technical Details
Message-ID: <39CA7117.318A6E11@inter.nl.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,578bd7383aa33288,start
X-Google-Attributes: gid1089d0,public
From: Rolf Schellenberger <b.schellenberg@inter.nl.net>
Subject: How to create a loop in java?
Date: 2000/09/21
Message-ID: <39CA7117.318A6E11@inter.nl.net>
X-Deja-AN: 672374004
Content-Transfer-Encoding: 7bit
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: The appropriate party according to NNTP-Posting-Host:
X-Trace: buty.wanadoo.nl 969525368 33921 194.134.200.78 (21 Sep 2000 08:36:08 GMT)
Organization: EuroNet Internet
Mime-Version: 1.0
NNTP-Posting-Date: 21 Sep 2000 08:36:08 GMT
Newsgroups: borland.public.jbuilder.java.api