【发布时间】:2016-02-05 18:25:19
【问题描述】:
我有一个任务来编写介绍“Stars”程序的方法。我已经找到了所有的 for 循环来打印设计,但是用它们编写类是我被绊倒的地方。我对编程还是很陌生,我确信我的代码中有很多愚蠢的错误。
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 " ";
}
【问题讨论】:
-
不清楚您的实际问题是什么,请您说得更清楚些好吗?
标签: java class for-loop data-structures return-type