0911 week test questions

0911 week test question drawing baby

Machine test instructions

Exam time, three classes

After encoding, send a message in the QQ group to call verification

Field verification results

01 Define a class and provide readme information

Class definition requirements:

Class name, DrawBaby

Has the attribute, name

Has the method, show_info

02 instantiate this class as an object

Claim:

Instantiate the DrawBaby class as an object, the object name is obj

The object's name value is the candidate's name, such as Lu Xiaobu

Improve the readme method show_info, when calling this method is to print

我是画画的baby吕小布

Completion criteria

Call show_info method

Can be displayed normally

我是画画的baby某某某

03 Method of drawing a straight line

Claim

Writing method writeLine

Call this method to print the following graphics

!!!!!

Completion criteria

Call the method and see an exclamation mark

04 How to print multiple lines

Claim

Writing method writeMultiLine

Receive an int parameter

Incoming number

Just print a few lines

!!!!!

E.g

Pass parameter is 3, the result will be

!!!!!
!!!!!
!!!!!

Completion criteria

Call method

Incoming parameters

See multiple exclamation marks

05 Calculate the result of multiplication of two numbers

Claim

Writing method multiplication

Receive two integers

Return the result of two numeric operations

Completion criteria

Execute the following code

System.out.println(obj.multiplication(2,3))

Can get result 6

Change the parameters to have the correct result printout

06 Draw a right triangle

Writing method writeTriangle

Receive a parameter

If you pass the value 3, it will draw three rows of triangles, and the output symbol is *

E.g:

*
**
***

If you pass the value 5, it will draw a triangle of five rows

Completion criteria

obj.writeTriangle(7)

Can draw 7 rows of triangles

07 Return a right triangle

Claim

Write the writeTriangleRet method

Its internal operation is the same as Question 06

Receive a parameter

The difference is that this method does not print output

It will return the triangle string

Completion criteria

System.out.println(obj.writeTriangleRet(3))

You can see three rows of triangles

Guess you like

Origin blog.csdn.net/ifubing/article/details/108513224