Hi, I am having problems when I call getUnion.
The error message are "getUnion(IntergerSet) in IntergerSet cannot be applied to ()" and "incompatible types"
where the arrows are.
Here is my code:
public void inputSet ()
{
Scanner input = new Scanner (System.in);
int value;
boolean arraySet[] = new boolean[100];
do
{
System.out.println("\nPlease enter a value or -1 to finish: ");
value = input.nextInt();
if(validEntry(value))
arraySet[value] = true;
else
System.out.printf("\nYou enter %d to finish entering values", value, "\n");
}while(value != -1);
System.out.println("\n\nIf you want to find the union of two sets press 'u': ");
String unionSets = input.next();
if("u".equalsIgnoreCase(unionSets))
---> System.out.printf("\nUNION", getUnion());
}
//Finding the union of two sets
public String getUnion(IntergerSet other)
{
IntergerSet res = new IntergerSet();
for(int i=0; i<SIZE; i++)
{
res.arraySet[i] = this.arraySet[i]||other.arraySet[i];
}
---> return res;
}
Enter your message below
Sign in or Join us (it's free).