this is the code for my sniper class (the same as my Gun class but different keys to switch the weapons)
both have a constructor (Spacemarinemodel1) because they need to attach to the object Spacemarinemodel1 when they enter the world. Once i compile this I get the syntax error constructer can not be applied to given typed, required Spacemarinemodel1. I think that there is an issue with both these classes (Sniper and Gun) having this same constructor, is there anyway that I can fix this or do I need to find a new way to get these objects to attach to the Spacemarine?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Gun here. * * @author (BradH) * @version (a version number or a date) */ public class Gun extends Weapons { private Spacemarinemodel1 spacemarinemodel1; public Gun(Spacemarinemodel1 spacemarinemodel1) { this.spacemarinemodel1 = spacemarinemodel1; } public void act() { Actor Bullet1; Bullet1 = getOneObjectAtOffset(0, 0, Bullet1.class); if("l".equals(Greenfoot.getKey())) { if(getWorld().getObjects(Bullet1.class).size()<=3) fire(); } int spacemarinemodel1X = spacemarinemodel1.getX(); int spacemarinemodel1Y = spacemarinemodel1.getY(); // Modify the xOffset and // yOffset to make the gun // appear in the correct // position. int xOffset = 27; int yOffset = -8; int x = spacemarinemodel1X + xOffset; int y = spacemarinemodel1Y + yOffset; setLocation(x, y); //switch weapon to Sniper if((Greenfoot.isKeyDown("2"))) getWorld().addObject(new Sniper(), getX(), getY()); //remove the first weapon if((Greenfoot.isKeyDown("2"))) getWorld().removeObject(this); return; } /** * fire the gun */ private void fire() { Ammo Bullet1 = new Bullet1(); getWorld().addObject(Bullet1, getX() , getY()); Bullet1.move(45); } }