问题描述
- Java 打印一个空心加号,要用parameter还有布尔来判断
-
- This method is used to print items to the screen. It should take in two parameters:
a. Number of items (int)
b. Item to print (String) - Notice that the top arm and the bottom arm of your plus sign are almost
identical? Create a method to print this arm. This method should take in
two parameters:
a. Size of arm (int) – the number of rows in the arm.
b. Top border (boolean) – indicates whether or not the arm’s border is
on the top. If this value is true, your method should print the border
on the top of the arm. If this value is false, your method should print
the border on the bottom of the arm. - Create a method to print the middle area of the plus sign. Both this
method and the previous method should call the printItems method to
print spaces and stars. - Create a method to get the plus sign size from the user. This method
should prompt the user for input, validate that it is correct input, reprompt
if necessary, and finally return the size back to the calling method. - Modify your main method to use the new methods you have written. The
main method should now:
a. Call your user input method to get the plus sign’s size.
b. Call the top/bottom arm method to print the top of the plus sign.
c. Call the middle area method to print the middle of the plus sign.
d. Call the top/bottom arm method again to print the bottom of the
plus sign.
- This method is used to print items to the screen. It should take in two parameters:
时间: 2024-11-08 23:39:31