# Algorithm Problem

• 01-21-2010, 09:21 PM
Aggy
Algorithm Problem
Can someone look at this algorithm for me and tell me why it does not compile and if it actually makes sense.

/**
* Creates a loop to determine how many frogs will take part in the race.
*/
public int Members(); //1
public int selected();
public int frogNumber();

public int Members = 0;
{
while(this.Members < 2)
this.frogNumber1 = false;
this.frogNumber2 = false;
this.frogNumber3 = false;
{
for (int frogNumber = 1; frogNumber < 3; frogNumber = frogNumber + 1)
OUDialog.confirm("Is " + this.frogNumber() + " taking part in the race");
if (selected = true)
{
frogNumber() = true;
selected++;
}
else
{
frogNumber() = false;
}
if (selected < 2)
{
OUDiag.confirm("A race must have at least two runners to be able to start");
selected = 0;
}
}
}

I get the "missing method body, or declare adstract" on the line marked //1
• 01-21-2010, 09:28 PM
[RaIdEn]

Code:

```/** * Creates a loop to determine how many frogs will take part in the race. */ public int Members(); //1 public int selected(); public int frogNumber(); public int Members = 0; { while(this.Members < 2) this.frogNumber1 = false; this.frogNumber2 = false; this.frogNumber3 = false; { for (int frogNumber = 1; frogNumber < 3; frogNumber = frogNumber + 1) OUDialog.confirm("Is " + this.frogNumber() + " taking part in the race"); if (selected = true) { frogNumber() = true; selected++; } else { frogNumber() = false; } if (selected < 2) { OUDiag.confirm("A race must have at least two runners to be able to start"); selected = 0; } } }```
Ok whats your reason why the code is not compiling?
• 01-21-2010, 10:02 PM
Aggy
I do indent and the reason it is not compiling is because it says that the variable Members is not recognised or declared, so do i declare it like I have done or do I have to declare something else.?
• 01-21-2010, 10:58 PM
senorbum
public int Members();
should be
public int members;

The same goes for the other variables.

That being said, there are lots of things wrong with the code. But that is a place for you to start.
• 01-22-2010, 12:00 AM