Results 1 to 4 of 4
  1. #1
    2341234 is offline Member
    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Default cannot find symbol - constructor Gun()

    hey guys new to this site, was just wondering if i could grab some help with an assignment.

    i dont know what im doing wrong, any help would be awesome.

    This is my PlayerShip class:

    public class PlayerShip
    {
    private int x;
    private Gun gun1;
    private Gun gun2;

    public PlayerShip(int playerx)
    {
    x = playerx;
    gun1 = new Gun();
    gun2 = new Gun();
    }
    }


    and this is my Gun class:

    public class Gun
    {
    private int x;
    private int power;
    private int points;
    private int bonus;
    private boolean justFired;

    public Gun(int gunx, int gunpower)
    {
    x = gunx;
    power = gunpower;
    points = 0;
    bonus = 1;
    justFired = false;
    }

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    758
    Rep Power
    8

    Default Re: cannot find symbol - constructor Gun()

    If your question subject is the problem, it has already said what was wrong. It cannot find the default constructor in the Gun class. Default constructor means a constructor that doesn't require a parameter.

    If you look at your Gun class you only have a constructor that requires you to pass two ints parameter into it. If you need a default constructor then you need to create one.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,197
    Rep Power
    19

    Default Re: cannot find symbol - constructor Gun()

    And use code tags, not color tags to post code. If you don't know what that means, go through the FAQs of the site and find out.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    2341234 is offline Member
    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

Similar Threads

  1. Constructor: Cannot find symbol compile error.
    By CaptainBeer in forum New To Java
    Replies: 4
    Last Post: 04-28-2011, 11:25 AM
  2. overridding constructor causes can not find symbol
    By bflhr673 in forum New To Java
    Replies: 5
    Last Post: 07-27-2010, 10:36 AM
  3. cannot find symbol constructor
    By daud in forum New To Java
    Replies: 9
    Last Post: 08-13-2009, 03:53 AM
  4. Replies: 9
    Last Post: 10-18-2008, 08:26 PM
  5. Error: cannot find symbol constructor
    By zoe in forum New To Java
    Replies: 1
    Last Post: 07-24-2007, 08:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •