gpt4 book ai didi

java - 该方法不适用于参数

转载 作者:行者123 更新时间:2023-12-02 00:13:35 25 4
gpt4 key购买 nike

我收到此错误:

the method pintar() in the type t33.Psicodelia is not applicable for the arguments (int,int,int,int,int,int)

我该如何解决这个问题?

我有两个类和主选项卡:

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();
}
}

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();
}
//================================================================

最佳答案

您调用了该方法

Psicodelia miPsicodelia;
miPsicodelia.pintar(width/2, height/2, height/4, 0, 0, 1);

但是您的 Psicodelia 类只有以下 pintar 方法:

public void pintar();

要按照您的方式调用它,您必须为方法 pintar() 提供所需的参数。

例如:

public void pintar(int a, int b, int c, int d, int e, int f){
// do whatever you want here
}

P.S.:您是否在任何地方实例化您的 miPsicodelia 对象?如果不是,这会给你一个 NullPointerException

关于java - 该方法不适用于参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12294297/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com