Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Why am I getting this? If you need more of the code, please ask.Thanks. Not poss

ID: 3618130 • Letter: W

Question

Why am I getting this? If you need more of the code, please ask.Thanks.

Not possible:
-MovingCircle class IS in the same folder
-awt.* has been imported

*** Error ***
-------------
File: C:UsersClass2013Desktop ullprogramsFallingCircle.java [line: 40]
Error: C:UsersClass2013Desktop ullprogramsFallingCircle.java:40: cannot find symbol
symbol : constructorMovingCircle(double,int,int,double,double)
location: class MovingCircle


Piece of code:

circle= new MovingCircle(DEFAULT_WINDOW_WIDTH * Math.random(),
                                0,
                                DEFAULT_CIRCLE_DIAMETER,
                                10 * Math.random() - 5,
                                3 * Math.random() + 3);


MovingCircle:

import java.awt.*;



public class MovingCircle {

private double xposition; // position of center ofcircle
private double yposition; // position of center ofcircle
private double move_x; //amount circle moves in Xdirection
private double move_y; //amount circle moves in Ydirection
private int Diameter; //size of circle


public MovingCircle (int xposition, int yposition, intdiameter, double deltax, double deltay)
{
  
    xposition = xposition;
    yposition = yposition;
    move_x = deltax;
    move_y = deltay;
    Diameter = diameter;
  
}
public void move()
{
  
    xposition = move_x + xposition;
    yposition = move_y + yposition;
}


public void paint(Graphics g)
{
       g.drawOval((int) xposition,(int) yposition, (int) Diameter, (int) Diameter);
}
}
     
   




Explanation / Answer

please rate - thanks Math.Random() generates a double number between 0 and 1. therefore your 1st parameter was double, when it was declaredint change the code to circle= new MovingCircle((int)(DEFAULT_WINDOW_WIDTH *Math.random()),                                  0,                                     DEFAULT_CIRCLE_DIAMETER,                                     10 * Math.random() - 5,                                     3 * Math.random() + 3); or change the declaration it worked better when I changed the code to have all "int" valuesfor the parameters, like this circle= new MovingCircle((int)(DEFAULT_WINDOW_WIDTH *Math.random()),                               0,                                     DEFAULT_CIRCLE_DIAMETER,                                     (int)( 10 * Math.random() - 5),                                     (int)(3 * Math.random() + 3));

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote