Hey everyone, I have my code written I just have one error I am stuck on, any help is greatly appreciated, thanks in advance.
My one error is on line 80 saying "illegal start of expression" pointing at the 'p' of public
import javax.swing.*;
import BreezySwing.*;
public class binary extends GBFrame
{
private JLabel ArrayLengthLabel;
private JLabel DataEntryLabel;
private JLabel TargetValueLabel;
private IntegerField ArrayLengthField;
private IntegerField DataEntryField;
private IntegerField TargetValueField;
private JButton SetLengthButton;
private JButton InsertDataButton;
private JButton SearchButton;
int count = 0;
int search;
int k = 0;
boolean exchangeMade = true;
int temp = 0;
int[] fin = new int[10];
int left = 0;
int right =a.length -1;
public binary()
{
ArrayLengthLabel = addLabel ("Array Length" ,1,1,1,1);
DataEntryLabel = addLabel ("Data Entry" ,1,2,1,1);
TargetValueLabel = addLabel ("Target Value" ,1,3,1,1);
ArrayLengthField = addIntegerField (0 ,2,1,1,1);
DataEntryField = addIntegerField (0 ,2,2,1,1);
TargetValueField = addIntegerField (0 ,2,3,1,1);
SetLengthButton = addButton ("Set Length" ,3,1,1,1);
InsertDataButton = addButton ("Insert Data" ,3,2,1,1);
SearchButton = addButton ("Search" ,3,3,1,1);
}
public void buttonClicked(JButton buttonObj)
{
if(buttonObj == SetLengthButton)
{
int[] fin = new int[ArrayLengthField.getNumber()];
}
else if(buttonObj == InsertDataButton)
{
fin[count] = DataEntryField.getNumber();
count++;
while((k < fin.length -1) && exchangeMade)
{
exchangeMade = false;
k++;
for(int j = 0; j < fin.length - k; j++)
{
if(fin[j] > fin[j+1])
{
temp = fin[j+1];
fin[j] = fin[j+1];
fin[j] = temp;
exchangeMade = true;
}
}
}
}
else if(buttonObj == SearchButton)
{
search = TargetValueField.getNumber();
while (left <= right)
{
int midpoint = (left + right)/2;
if(fin[midpoint] == searchValue)
return midpoint;
else if (fin[midpoint] < searchValue)
left = midpoint + 1;
else
right = midpoint -1;
}
return -1;
}
public static void main (String[] args)
{
binary theGUI = new binary();
theGUI.setSize(500, 500);
theGUI.setVisible(true);
}
;
}
}