0
我有一個任務來編寫介紹「星級」程序的方法。我已經找到了所有for循環來打印設計,但是用它們編寫類是我被絆倒的地方。我對編程還很陌生,我確信我的代碼中有很多愚蠢的錯誤。創建一個類,併爲STARS程序編寫方法
Here's the Document of the Stars output
public class STARS {
Scanner scan = new Scanner(System.in);
public int rows;
public String part1, part2, part3, part4, part5;
public STARS(int rows){
}
private static String part1(int rows){
for (int i = 0; i < rows; i++) {
for (int stars = 0; stars < rows; stars++) {
System.out.print("*");
}
System.out.println("");
}
return " ";
}
private static String part2(int rows){
System.out.println("");
for (int i = 1; i <= rows; i++) {
for (int star = 1; star <= i; star++) {
System.out.print("*");
}
System.out.println("");
}
return " ";
}
您的實際問題並不明顯,請您說清楚一點? – tddmonkey