“kelas” Kode Jawaban

kelas

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

Kelas

uTCFDSWDUTVSAFDVKLJHGBSDICFDSVFCGSFVSFVDVFVADVFVAV
Frightened Flamingo

kelas

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

kelas

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

Jawaban yang mirip dengan “kelas”

Pertanyaan yang mirip dengan “kelas”

Lebih banyak jawaban terkait untuk “kelas” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya