#code not compiling
1 messages ยท Page 1 of 1 (latest)
โ This post has been reserved for your question.
Hey @glacial prawn! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
I dunno this IDE. Maybe the Dice class is not where it should be
Ive actullay been getting this error now Implicit super constructor sketch_230824b.CollisionDetector() is undefined. Must explicitly invoke another constructor here is my constructor Avatarang(int x, int y, int z, int scale) within my code onyl error im getting
You're getting that error on a constructor in a class that is defined as public class MyClass extends Something. As in, it has an 'extends' on it.
All constructors start with super(). They just do. If you fail to write it, javac assumes you forgot and acts like it's there. The only way to avoid it is either [A] add a this() call (not relevant here, just mentioning it to be complete), or [B] you explicitly add it, or some other super(someArgs) call.
So, your constructor starts with it too. And the thing is, your parent class does not have a no-args constructor. So, javac silently acts like super(); is up top, and then fails on this invisible statement because it is referring to a non-existent constructor. The solution is to stick super(some, args, here); up top. Without seeing the code/API of the superclass I couldn't tell you what it should look like.
Now, object does have a no-arguments constructor, which is why I know this error must be occurring on a class that extends something. (because all classes extend something. If you fail to mention that, javac acts like you wrote extends java.lang.Object). Javac does a number of these implicit things ๐
Ahh ok I understand so is the super class suppose to resemble the parent class or the current class its currently in ?
super(avx,avy,avz,spdx,spdy,spdz,avscale,0,0,0);
float x, y, z;
float scale;
Avatarang(int x, int y, int z, int scale) {
this.x = x;
this.y = y;
this.z = z;
this.scale = scale;
}
void display() {
pushMatrix();
translate(x, y, z);
scale(scale);
// Head
noStroke();
fill(240, 150, 150);
sphere(1);
// Body
translate(0, 1.5, 0);
fill(0, 100, 255);
box(1.2, 2, 0.6);
// Arms
translate(-0.6, -0.7, 0);
fill(150, 150, 240);
box(0.4, 1.2, 0.4);
translate(1.2, 0, 0);
box(0.4, 1.2, 0.4);
// Legs
translate(-0.4, 2.4, 0);
fill(150, 240, 150);
box(0.6, 1.4, 0.6);
translate(0.8, 0, 0);
box(0.6, 1.4, 0.6);
popMatrix();
}
void move() {
// get ready for movement in next frame.
myx = round(myx + speedX) ;
myy = round(myy + speedY) ;
myz = round(myz + speedZ);
detectCollisions();
}
int [] getBoundingBox() {
int [] result = new int[6];
result[0] = myx-round(40*myscale) ; // left extreme of left arm
result[1] = myy - round(30*myscale); // top of hat
result[2] = myz - round(25*myscale); // back of head
result[3] = myx + round(myscale*max(20,40)); // max of right leg & arm
result[4] = myy + round(120*myscale) ; // bottom of legs
result[5] = myz + round(25*myscale); // front of head
return result ;
}
} ```
here is my current code that extends the collision detector class
This message has been formatted automatically. You can disable this using /preferences.
Your Avatarang's superclass is CollisionDetector.
CollisionDetector is the one that doesn't have a no-args constructor.
You need to start your constructor with super(abc). What's abc? Dunno - I don't know what CollissionDetector is.
๐ค Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.