Hello,

I have three classes: Circle, Canvas and GameBoard.

When I try to compile this I get the error

'cannot resolve symbol - constructor Circle(int,int,java.lang.string)'

I noticed if I delete the parameters of the Circle it will compile. Please could anyone tell me why it doesnt understand the parameters?
Do the parameters have to be clearly declared the same in the Circle class?

Below are the Gameboard and Circle classes.

Thanks

stevetook

GameBoard class:

import java.util.ArrayList;


public class GameBoard
{
private ArrayList locations;


public GameBoard()
{
locations = new ArrayList();


locations.add(new Circle(130,50,"black"));
locations.add(new Circle(140,50,"black"));
}


}


Circle class:


import java.awt.*;
import java.awt.geom.*;


public class Circle
{
private int diameter;
private int xPosition;
private int yPosition;
private String color;
private boolean isVisible;



public Circle()
{
diameter = 30;
xPosition = 20;
yPosition = 60;
color = "blue";
isVisible = false;
}


public void makeVisible()
{
isVisible = true;
draw();
}

Edited 3 Years Ago by happygeek: fixed formatting

Isn't the constructor supposed to have five variables

Circle(130,50,"black"));

You only have three there?

his Circle class only has a no-argument constructor ;)

Please explain what is meant by a 'no-argument' constructor in the Circle class to mere novice?

Thanks

stevetook

no-argument constructor is your one

public Circle()
{
diameter = 30;
xPosition = 20;
yPosition = 60;
color = "blue";
isVisible = false;
}

constructor with argument is something like this dude

public Circle( int d, int x, int y, String str, boolean b)
{
diameter = d;
xPosition = x;
yPosition = y;
color = str;
isVisible = b;
}

you want to past values and not to set them default only... :mrgreen:

you want to past values and not to set them default only... :mrgreen:

Thanks for such a good answer that is understandable :) ..your example is also very good and this should come in handy for other beginners.

I will work on it again now and hopefully get some results..

Thanks again..

stevetook

I will work on it again now and hopefully get some results..

Success.. :cheesy:

As advised by the GrandMaster himself peter_budo I used a constructor with an argument. I still had to display the circle/s on the canvas and wasnt sure what to do so I modified the Circle class to 'draw' when creating a circle object. This way when the ArrayList ran in the GameBoard class it displayed the circle :lol: Funny I guess to the experts but as a beginner to java this took atleast an hour to work out :eek:

Thanks for your help everyone..:)

stevetook

lol, no grandMaster, I'm studing and working with java only 3 years and still have lot to learn,
if somebody should be called GrandMaster here than jwenting is my choise

This question has already been answered. Start a new discussion instead.