我正在運行一個名爲mycatmychoice的項目正在運行但未顯示。我知道我錯過了一些東西,但不知道是什麼。任何意見是極大的讚賞。這是一個較大項目的一小部分,但我需要先讓這部分工作。我沒有收到任何錯誤,但輸出不顯示。項目正在運行但未顯示
package mycatmychoice;
public final class Mycatmychoice {
public static void main(String[] args) {
}
//variables
private String name;
private String breed;
private String gender;
private String color;
private int age;
public String introducecat;
//constructor
public Mycatmychoice(String breed, String name, String gender, String color, int age) {
this.breed = breed;
this.breed = name;
this.gender = gender;
this.color = color;
this.age = age;
}
//Returns the value of name
public String getname() {
return name;
}
//Sets the name variable.
public void setname(String name) {
this.name = name;
}
//Returns the value of breed
public String getbreed() {
return breed;
}
//Sets the breed variable.
public void setbreed(String breed) {
this.breed = breed;
}
//Returns the value of gender
public String getgender() {
return gender;
}
//Sets the gender variable.
public void setgender(String gender) {
this.gender = gender;
}
//Returns the value of color
public String getcolor() {
return color;
}
//Sets the color variable.
public void setcolor(String color) {
this.color = color;
}
//Returns the value of age
public int getage() {
return age;
}
//Sets the age variable.
public void setage(int age) {
this.age = age;
}
public void introducecat() {
System.out.printf("Say hi to %s who is a %d year old %s %s %s cat \n", getname(), getage(), getgender(), getcolor(), getbreed());
}
}
在main方法中需要一些語句。 – laune
什麼樣的聲明?我是一名初學者。 – Shelly