die Methode ist nicht anwendbar für die Argumente
Bekomme ich diesen Fehler:
die Methode pintar() in den Typ t33.Psicodelia ist nicht anwendbar für die Argumente (int,int,int,int,int,int)
Wie kann ich dieses Problem lösen?
Ich habe zwei Klassen und der main-Registerkarte:
Klasse 1
public class Logica {
Psicodelia miPsicodelia;
public Logica() {
}
public void pintar() {
miPsicodelia.pintar(width/2, height/2, height/4, 0, 0, 1);
miPsicodelia.kaleidouno(posX, posY, rad, ang, depth, tam1);
}
public void pressed() {
miPsicodelia.pressed();
}
}
Klasse 2
public class Psicodelia {
private float anguloGrande;
private int numBolas, contador;
public Psicodelia() {
stroke(255);
this.anguloGrande = 0.0;
this.numBolas = 7;
}
public void pintar() {
//fill((int)random(0, 255), (int)random(0, 255), (int)random(0, 255));
fill(255, 255, 0, (int)random(20, 100));
pintar(width/2, height/2, height/4, 0, 0, 1);
anguloGrande += .02; //velocidad de rotacion
}
public void kaleidouno(float posX, float posY, float rad, float ang, int depth, float tam) { //pinteme las bolas en la pos posX, posY, reciba un float de radianes y de angulos, y por ultimo un int de profundidad
if (depth < contador) {
tam=(int)random(0.5, 1.5);
float anguloPeq = TWO_PI/numBolas;
for (int i=0; i < numBolas; i++) {
float nuevoRad = rad/2; //distancia y tamaño de las bolas entre ellas
float nuevoAng = ang + i*anguloPeq - anguloGrande;
float X = cos(nuevoAng)*rad + posX;
float Y = sin(nuevoAng)*rad + posY;
pintar(X, Y, nuevoRad, nuevoAng, depth + 1, 1);
}
}
else if (rad < 2) {
ellipse(posX, posY, 2.0*tam, 2.0*tam);
}
else {
ellipse(posX, posY, rad*2.0, rad*2.0);
}
}
public void pressed() {
contador++;
if (contador >= 3) {
contador--;
}
}
float getPosX () {
return posX ;
}
float getPosY () {
return posY ;
}
}
//and the main tab
Logica miLogica;
//================================================================
void setup() {
size(800,600);
smooth();
miLogica= new Logica();
}
//================================================================
void draw() {
background(0);
miLogica.pintar();
}
//================================================================
void mousePressed() {
miLogica.pressed();
}
//================================================================
- Wie sieht es in der Klasse
Psicodelia
in der Methodepintar()
dass Sie anrufenpintar(width/2, height/2, height/4, 0, 0, 1);
als Sie sollten eigentlich anrufenkaleidouno(width/2, height/2, height/4, 0, 0, 1);
. - wo ist die definition der Funktion für pintar(int,int,.,.,.,.,.,.)?? Sie sind mit den mathod als pintar() ohne argument in der Klasse 2;
Du musst angemeldet sein, um einen Kommentar abzugeben.
Du die Methode aufgerufen
Aber Ihre
Psicodelia
Klasse hat nur folgendenpintar
Methode:Nennen Sie es, wie Sie Tat, Sie müssen die Methode
pintar()
den gewünschten parameter.Beispiel:
P. S.: Tun Sie instanziieren Sie Ihr
miPsicodelia
Objekt überall? Erfolgt dieses nicht, erhalten Sie eineNullPointerException
.public void pintar(int a, int b, int c, int d, int e, int f)
Methode in IhrerPsicodelia
Klasse? Wo genau tritt der Fehler auftaucht? Eine Zeilennummer helfen würde.miPsicodelia.pintar(width/2, height/2, height/4, 0, 0, 1);
Sie bedeuten, dass Sie gehen in die KlassemiPsicodelia
(das istPsicodelia
) und suchen Sie nach der Methode 'pintar' mit dem parameter 'int,int,int,int,int,int', das heißt, Sie brauchen eine Methodepublic void pintar(int a, int b, int c, int d, int e, int f){...}
Methode in IhrerPsicodelia
Klasse. Weil es bei Ihnen moment nurpublic void pintar(){...}
Sie haben wollen, deklarieren Sie eine neue Methode.Gut, es sei denn, ich vermisse etwas, Ihre
public void pintar()
Methode deklariert wird, die keine Parameter, so können Sie nicht rufen Sie es mit jedem. Sie würden es erklären mit Ihrer gewünschten Anzahl und Typen von Parametern:public void pintar() { //... }
ohne Parameter. Also, wenn Sie versuchen, zu nennenmiPsicodelia.pintar(width/2, height/2, height/4, 0, 0, 1);
Ihre Methode nicht wissen, was zu tun mit den zahlen wird es.