“classe” Respostas de código

classe

//class in es6 are just functional constructor.
class PersonES6{
  constructor(firstname,lastname,age){
    this.firstname= firstname;
    this.lastname=lastname;
    this.age=age
  }
  aboutPerson(){
  console.log(`My name is ${this.firstname} ${this.lastname} and I am ${this.age} years old`)
  }
}

const shirshakES6= new Person('Shirshak','Kandel',25)
shirshakES6.aboutPerson();
Shirshak kandel

Classe

uTCFDSWDUTVSAFDVKLJHGBSDICFDSVFCGSFVSFVDVFVADVFVAV
Frightened Flamingo

classe

class Person:
    def __init__(self, name, sex, profession):
        # data members (instance variables)
        self.name = name
        self.sex = sex
        self.profession = profession

    # Behavior (instance methods)
    def show(self):
        print('Name:', self.name, 'Sex:', self.sex, 'Profession:', self.profession)

    # Behavior (instance methods)
    def work(self):
        print(self.name, 'working as a', self.profession)
Beast

classe

# class
class Enum:
    Tim, Bill, Joe = range(1,4)
print(Enum.Tim == 1)			# return True
Impossible Impala

Respostas semelhantes a “classe”

Perguntas semelhantes a “classe”

Mais respostas relacionadas para “classe” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código