开发者

Java: Self defined method parameter problems

I'm trying to learn basic animation out of Lambert/Osborne's Fundamentals of Java. This method is defined within the Circle class, and taken right out of the book.

    public void move(){
    move((int)(velocity * Math.cos(Math.toRadians(direction))), (int)(velocity * Mat开发者_如何转开发h.sin(Math.toRadians(direction))));
}

And I get the error: Circle.java:49: move() in Circle cannot be applied to (int,int) move((int)(velocity * Math.cos(Math.toRadians(direction))), (int)(velocity * Math.sin(Math.toRadians(direction))));

I understand that it's a parameter problem, I just don't know how to fix it. Thanks!


Have you defined the other move method, the one that takes two parameters of type int? The move method is overloaded, and the two-parameter version must also be declared (in class Circle or a superclass of class Circle).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜