我应该为 ColorImage 参数输入什么?

时间:2021-08-01 17:36:34

标签: java

我正在尝试创建一个足球游戏,我必须为类射手完成此方法:

import comp102x.ColorImage;

public class Shooter
{
/**
 * Shoots the football horizontally by incrementing the x position of the football image 
   repeatly.
 * 
 * Hints:
 * 1. Write a loop to complete this method.
 * 2. Use the getX()and setX(int) instance method of the ColorImage class.
 * 3. Call the pause(int) method at the end of each loop iteration to spare time for the 
   screen to update.
 * 4. The suggested parameter for calling the pause(int) method is 2, i.e. pause(2).
 *    
 * @param footballImage The football image to be updated.
 * @param numberOfTimes The number of times to increment the x position of the football image.
 * @param unitDistance The amount to increment for the x position for each time.
 */

public void shoot(ColorImage footballImage, int numberOfTimes, int unitDistance)
{
    // write your code after this line
for (int max = 1; max <= numberOfTimes; numberOfTimes++) {
    footballImage.setX(footballImage.getX() + 1);
    pause(2);
}
    
    
    
}

到目前为止,我尝试编写如上所示的方法,这基本上意味着只要不超过 numberOfTimes,就会运行 for 循环,并且 FootballImage 将以 1 为增量向右移动。但是当我尝试运行代码时,当它要求输入参数的值时,我不知道向参数 ColorImage FootballImage 输入什么。我尝试输入足球图片的名称(b2.png),但它不接受。你应该输入什么?

编辑:当我运行拍摄方法时,这是弹出的内容:

enter image description here

我尝试输入足球的文件名,但它不起作用,因为您可以看到该消息出现^

我应该为 ColorImage 参数输入什么?

0 个答案:

没有答案