Results 1 to 4 of 4
- 04-02-2012, 04:16 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 2
- Rep Power
- 0
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;
}
- 04-02-2012, 06:03 AM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 762
- Rep Power
- 14
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.Website: Learn Java by Examples
- 04-02-2012, 07:51 AM #3
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.
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 04-02-2012, 10:48 AM #4
Member
- Join Date
- Apr 2012
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Constructor: Cannot find symbol compile error.
By CaptainBeer in forum New To JavaReplies: 4Last Post: 04-28-2011, 12:25 PM -
overridding constructor causes can not find symbol
By bflhr673 in forum New To JavaReplies: 5Last Post: 07-27-2010, 11:36 AM -
cannot find symbol constructor
By daud in forum New To JavaReplies: 9Last Post: 08-13-2009, 04:53 AM -
cannot find symbol symbol :constructor Error. Please help! =(
By KalEl in forum New To JavaReplies: 9Last Post: 10-18-2008, 09:26 PM -
Error: cannot find symbol constructor
By zoe in forum New To JavaReplies: 1Last Post: 07-24-2007, 09:24 PM
Bookmarks