代码语言:javascript复制
package *;
/**
* @program: data-structure
* @description: 长方形
* @author: ChenWenLong
* @create: 2019-09-10 14:54
**/
public class Rectangle {
public static void main(String[] args) {
printRectangle(2,3);
}
/**
* 功能描述:
* 〈打印指定长度和宽度的,长方形〉
*
* @params : [length, wideth]
* @return : void
* @author : cwl
* @date : 2019/9/10 14:57
*/
public static void printRectangle(int length,int wideth) {
if(length <= 0 || wideth <= 0){
throw new RuntimeException("number mast greater than zero");
}
if (length > 1 || wideth > 1) {
for (int i = 1; i <= length; i ) {
for (int j = 1; j <= wideth; j ) {
System.out.print("*");
}
System.out.println();
}
} else {
System.out.println("数字应大于1");
}
}
}