Your code should indent properly.
-- Add a comment section before each method. Briefly document what this
method do. What is the meaning of the argument.
Write a Java program to:
1. Write 4 methods. Each takes one integer argument, that is the size of the
pattern. Each of these 4 methods will print a different pattern on screen,
square, box, grid and cross.
How the patterns look like at size 5:
(1) square: a solid 5x5 square
*****
*****
*****
*****
*****
(2) box: a empty 5x5 box
*****
* *
* *
* *
*****
(3) grid:
*****
* * *
*****
* * *
*****
(4) cross: a cross with 5 units width and height
* *
* *
*
* *
* *
2. Ask user to select from a list of patterns:
(1) square, (2) box, (3) cross
3. Ask user to enter the size.
4. Print the specified pattern on screen.
5. Ask user if she/he wants to print another, repeat step 2-4
until user says no.
For example, this is what your program will print for a box of
size 3:
***
* *
***
Another example, this is what your program will print for a cross of
size 8:
* *
* *
* *
**
**
* *
* *
* *
Another example, this is what your program will print for a grid of
size 6:
******
* * *
******
* * *
******
* * *
How to approach this problem:
1. Work on one method at a time. Test each method by calling it from
main method with a hard-coded size for parameter.
2. After all methods are working, add code to ask user to select
pattern and enter size. Call different method based on user's
selection.
3. Once 2. is working correctly, put entire thing inside a loop
to repeat until user quit.
I want to know which type of method to use
Thank You
This post has been edited by BabyKodou: 26 November 2009 - 10:59 AM

New Topic/Question
This topic is locked




MultiQuote








|