基本上,我的主要问题来自程序的后两种方法,即drawBlock和drawTiers。它被设计为输出蛋糕的图像,尽管它确实会以其原本的方式来做。例如,该程序仅允许3到9(3,5,7,9)之间的奇数输入,它使用这些来决定要打印多少蛋糕。输入3应该可以使我们
$batch = $service->createBatch();
$googleServiceDriveFile = new \Google_Service_Drive_DriveFile(['name' => uniqid()]);
$request = $service->files->copy($googleFileId, $googleServiceDriveFile, ['fields' => 'id']);
$batch->add($request);
$results = $batch->execute();
5可以让我们
*
|
|
=========
|..xxx..|
/^^^^^^^^^^^^^^^^^^^^^^^^^^^\
[|_______||_______||_______|]
[|___||_______||_______|___|]
\===========================/
分别。 drawTiers具有一个int参数,而drawBlock具有两个int参数。层是用来确定每次调用drawBlock时层的宽度的,它是假定使第二个参数变大,从而使层变宽。事情是我的程序包含了一个层值,但它却无济于事,因为我为每种可能的情况编写了代码,因此它被忽略了。这不是要完成的意思,我想知道如何正确使用tiers值。抱歉,如果我没有正确解释,但是我将不胜感激。同样,“ sizeParam”也就是用户输入向下发送到方法中的内容。
*
|
|
=========
|..xxx..|
|..xxx..|
|........xxxxxxxxx........|
|........xxxxxxxxx........|
/^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\
[|_______||_______||_______||_______||_______|]
[|___||_______||_______||_______||_______|___|]
[|_______||_______||_______||_______||_______|]
[|___||_______||_______||_______||_______|___|]
\=============================================/
答案 0 :(得分:0)
关键是打印字符而不是全行。这样,您可以根据size参数来控制每层需要打印的内容。
这是一个尝试。您可能需要根据实际的输出要求调整一些数字
public static void drawTiersNew (int tiersParam) {
for (int level = 0; level < tiersParam/2 ; level++) {
drawBlockNew(level, tiersParam/2);
}
}
public static void drawBlockNew (int level, int tierParam) {
for (int repeat = 1; repeat <= tierParam; repeat++) {
for (int count = 0; count < (tierParam - level)*9 ; count++) {
System.out.print(' ');
}
System.out.print('|');
for (int count = 0; count < (2 + 6 * level) ; count++) {
System.out.print('.');
}
for (int count = 0; count < (3 + 6 * level); count++) {
System.out.print('x');
}
for (int count = 0; count < (2 + 6 * level); count++) {
System.out.print('.');
}
System.out.print('|');
System.out.print('\n');
}
}
这是它为 drawTiersNew(9)
打印的内容 |..xxx..|
|..xxx..|
|..xxx..|
|..xxx..|
|........xxxxxxxxx........|
|........xxxxxxxxx........|
|........xxxxxxxxx........|
|........xxxxxxxxx........|
|..............xxxxxxxxxxxxxxx..............|
|..............xxxxxxxxxxxxxxx..............|
|..............xxxxxxxxxxxxxxx..............|
|..............xxxxxxxxxxxxxxx..............|
|....................xxxxxxxxxxxxxxxxxxxxx....................|
|....................xxxxxxxxxxxxxxxxxxxxx....................|
|....................xxxxxxxxxxxxxxxxxxxxx....................|
|....................xxxxxxxxxxxxxxxxxxxxx....................|