arguments of unequal length?

Ok so I initialise the class Boomerang like so:

boom = new Boomerang(PWIDTH, PHEIGHT, bricksMan, imsLoader, (int)(period/1000000L));

This is the class with constructor:

public class Boomerang extends Sprite
{
    private static double DURATION = 0.5;  // secs
    // total time to cycle through all the images
    private int period;    // in ms; the game's animation period
    private BricksManager brickMan;
    private Point[] boomPath;
    


public Boomerang (int w, int h, Bricks Manager bm, ImagesLoader imsLd, int p){

 
    }
} 

The amount and type of arguments are correct, yet my IDE still tells me they aren’t and it won’t compile because of that, am I missing something obvious (I usually am)?

After a click look it seems fine, but I cannot be sure since I do not know all of the types of your variables.

Are you using eclipse? if so then I have this problem all the time, eclipse will throw a hissy fit and you will just have to play along and try to find a way to make it happy. try selecting everything, cutting it, and then pasting it right back in the same spot, or something of that nature, often just the complete change it code will make it happy.

I honestly don’t know why this happens, and if anyone knows a better solution, I would really like to know because this happens to me very often and it is a PITA!

hope I helped,
h3ckboy

I’m using netbeans and cutting and pasting the code both individual variables and the whole argument hasn’t worked :frowning:

…umm in your args you have “Bricks Manager” it should be “BricksManager” right? that space will throw it off because classes I don’t think are suppose to have a space in their name.

yeah, stumpy is probably right, AFAIK you cannot have class names with spaces in them, so maybe it is treating htem differently.

yer that was a typo

ok so that fixed the problem initialising it.

BUT

now it says there are no arguments in the actual class…

Here’s the log:

warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\Users\charlotte\Documents\NetBeansProjects\LabRat\src\labrat\Boomerang.java:27: error: constructor Sprite in class Sprite cannot be applied to given types;
public Boomerang (int w, int h, BricksManager bm, ImagesLoader imsLd, int p){
  required: int,int,int,int,ImagesLoader,String
  found: no arguments

Know this sounds very obvious but have you not saved it? It looks like it is pulling files/data from an older save hence why it needs ints and then some other stuff.

Do you remember any method with that argument? int int int int ImagesLoader String

If it was an old method that you changed then it is most likely not getting the new files.

ok, so now it’s asking for the arguments of the superclass not the boomerang class, I already have a class that extends Sprite and doesn’t use its arguments, any ideas?

hmmm I am still confused on how your code structure looks like. You may be doing something wrong with inheritance.

Also, can you show what boom is? Is it Boomrang boom; or something else boom;

this is the super class, Sprite:

public class Sprite 
{
  // default step sizes (how far to move in each update)
  private static int XSTEP = 5; 
  private static int YSTEP = 5;

  // default dimensions when there is no image
  private static final int SIZE = 12;   

  // image-related
  private ImagesLoader imsLoader;
  private String imageName;
  private BufferedImage image;
  private int width, height;     // image dimensions

  private ImagesPlayer player;  // for playing a loop of images
  private boolean isLooping;

  private int pWidth, pHeight;   // panel dimensions

  private boolean isActive = true;      
  // a sprite is updated and drawn only when it is active

  // protected vars
  protected int locx, locy;        // location of sprite
  protected int dx, dy;            // amount to move for each update



  public Sprite(int x, int y, int w, int h, ImagesLoader imsLd, String name) 
  { 

Boomerang extends Sprite.

Here is another class that extends sprite but does not have this issue:

public class JumperSprite extends Sprite
{
  private static double DURATION = 0.5;  // secs
    // total time to cycle through all the images

  private static final int NOT_JUMPING = 0;   
  private static final int RISING = 1;   
  private static final int FALLING = 2;   
  // used by vertMoveMode 
  //  (in J2SE 1.5 we could use a enumeration for these)

  private static final int MAX_UP_STEPS = 8;
    // max number of steps to take when rising upwards in a jump


  private int period;    // in ms; the game's animation period

  private boolean isFacingRight, isStill;

  private int vertMoveMode;
    /* can be NOT_JUMPING, RISING, or FALLING */
  private int vertStep;   // distance to move vertically in one step
  private int upCount;

  private BricksManager brickMan;
  private int moveSize;   // obtained from BricksManager

  private int xWorld, yWorld;
    /* the current position of the sprite in 'world' coordinates.
       The x-values may be negative. The y-values will be between
       0 and pHeight. */ 
  

  public JumperSprite(int w, int h, int brickMvSz, BricksManager bm, 
                                        ImagesLoader imsLd, int p)
  {
    super(w/2, h/2, w, h, imsLd, "robStandRight");

does that help?

Are you calling super(…) in Boomerang’s constructor?

How about showing us all of the code with issues, rather than tiny bits and hiding the real problem? :stuck_out_tongue:

No, I only call super in the class JumperSprite, not in the constructor.

Do you want the whole class lol? I’ll pastebin it if needed?

hi,

Orangy Tang is right, you have to call the super constructor in Boomerang, otherwise java will try to call the default one from Sprite ( without arguments ) … and you don’t have any.

I told you I always miss something obvious, the fact it was asking for Boomerang’s args first completely through me off lol.

Thanks guys it works now :slight_smile:

Hehe glad you got it working. I know of many times where it was not compiling I was like :o and it always turns out to be something silly.

Now we’ve solved the simple problem, onto something more fundamental - inheriting Boomerang and JumperSprite from Sprite is Bad and Wrong.

A boomerang is not a sprite, it’s a tangible object which happens to have a visible representation. That should probably be coded by a Boomerang class which has a Sprite as a member, not inheriting from Sprite.