
Ayuda con error Reason: actual or formal argument lists differ in length.
Publicado por dash (1 intervención) el 16/05/2023 18:53:29
Buenas, tengo un problema con este código.
El método getAnimalType() me muestra este error:
Method AnimalType in class clsPet cannot by applied to given types. Required: String. Found: no arguments. Reason: actual or formal argument lists differ in length.
Digamos que he buscado ejemplos del error y entiendo por qué podría saltar normalmente, pero la verdad no veo por qué me está saltando a mí
aca el codigo de la clase pet donde se define el metodo. Gracias
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
public class ctlPet {
public ctlPet() {
}
public boolean CreatePet(clsPet pet) {
try{
switch (pet.getAnimalType()) {
case "Gato":
break;
case "Perro":
break;
}
return true;
}catch(Exception e) {
return false;
}
}
public boolean EditPet(clsPet pet) {
try{
switch(pet.getAnimalType()){
case "Gato":
break;
case "Perro":
break;
}
return true;
}catch(Exception e) {
return false;
}
}
public boolean DeletePet(clsPet pet) {
try{
switch(pet.getAnimalType()){
case "Gato":
break;
case "Perro":
break;
}
return true;
}catch(Exception e) {
return false;
}
}
public clsPet SearchPet(String code, String type) {
clsPet pet = null;
try{
switch(type) {
case "Gato":
break;
case "Perro":
break;
}
return pet;
}catch(Exception e) {
return pet;
}
}
}
El método getAnimalType() me muestra este error:
Method AnimalType in class clsPet cannot by applied to given types. Required: String. Found: no arguments. Reason: actual or formal argument lists differ in length.
Digamos que he buscado ejemplos del error y entiendo por qué podría saltar normalmente, pero la verdad no veo por qué me está saltando a mí
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
public class clspet implements IAnimal, IVertebrate{
private String code;
private String name;
private int born_year;
private String color;
private String healthStatus;
private String sound;
public clspet (String code, String name,int born_year, String color, String healthStatus){
this.code = code;
this.name= name;
this.born_year= born_year;
this.color= color;
this.healthStatus= healthStatus;
}
public clspet (){}
public void Eat(){
System.out.println(" La Mascota "+this.name+" está comiendo");
}
public void Move(){
System.out.println(" La Mascota "+this.name+" se está moviendo");
}
public void Sound(){
System.out.print("La Mascota "+this.name);
}
public void walkAround(){
System.out.print("La mascota "+this.name+" está");
}
public String getCode() {
return code;
}
public String getName() {
return name;
}
public int getBorn_year() {
return born_year;
}
public String getColor() {
return color;
}
public String getHealthStatus() {
return healthStatus;
}
public void setCode(String code) {
this.code = code;
}
public void setName(String name) {
this.name = name;
}
public void setBorn_year(int born_year) {
this.born_year = born_year;
}
public void setColor(String color) {
this.color = color;
}
public void setHealthStatus(String healthStatus) {
this.healthStatus = healthStatus;
}
public String getAnimalType() {
return "Domestico";
}
public int getNumberOfBones() {
return 0;
}
}
aca el codigo de la clase pet donde se define el metodo. Gracias
Valora esta pregunta


0