How to use an interface to define a class with a constructor

problem description

I have a requirement now

interface IGun {
    (putBullet: number):void;
    shot():void;
}
class Gun implements IGun {
    bulletCount: number = 0;
    construtor(putBullet: number) {
        this.bulletCount = putBullet;
    }
    shot() {
        // shotting bullet in boundary of bulletCount;
    }
}

the environmental background of the problems and what methods you have tried

interface IGun {
    constructor(putBullet: number):void;
    shot():void;
}

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

both definitions of interface are wrong. I want to know how to define them correctly.
I need help! Please!

Dec.24,2021


class Gun implements IGun {
    bulletCount: number = 0;
    "construtor"(putBullet: number) {
        this.bulletCount = putBullet;
    }
    shot() {
        // shotting bullet in boundary of bulletCount;
    }
}

take a look at link description

Menu