Write an Enlistee class that keeps data attributes for the following pieces of information: • Enlistee name • Enlistee number Next, write a class named Private that is a subclass of the Enlistee class. The Private class should keep data attributes for the following information: • Platoon number (an integer, such as 1, 2, or 3) • Years of service (also an integer)



Answer :

Answer:

function Enlistee( name, number ){

    constructor( ){

      super( ) ;

      this.name= name;

      this.number= number;

      this.Private= ( platoonNumber, yearOfService ) =>{

                             this.platoonNumber = platoonNumber;

                             this.yearOfService = yearOfService;

                             }

     }

}                

Explanation:

In Javascript, OOP ( object-oriented programming) just like in other object oriented programming languages, is used to create instance of a class object, which is a blueprint for a data structure.

Above is a class object called Enlistee and subclass "Private" with holds data of comrades enlisting in the military.