“Klasse” Code-Antworten

Klasse

//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

Klasse

uTCFDSWDUTVSAFDVKLJHGBSDICFDSVFCGSFVSFVDVFVADVFVAV
Frightened Flamingo

Klasse

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

Klasse

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

Ähnliche Antworten wie “Klasse”

Fragen ähnlich wie “Klasse”

Weitere verwandte Antworten zu “Klasse” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen