첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170
class Person:
    "부모 클래스"

    def __init__(self, name, phoneNumber):
        self.Name        = name
        self.PhoneNumber = phoneNumber

    def PrintData(self):
        print("Person(Name : {0}, Phone Number : {1})".format(self.Name, self.PhoneNumber))

class Student(Person):
    "자식 클래스"

    def __init__(self, name, phoneNumber, subject, studentID):
        Person.__init__(self, name, phoneNumber)

        self.Subject     = subject
        self.StudentID   = studentID

    def PrintData(self):
        Person.PrintData(self)
        print("Student(Subject : {0}, Student ID : {1})".format(self.Subject, self.StudentID))

student = Student("Marry", "010-654-1234", "Computer Science", "990999")

student.PrintData()

"""
Person(Name : Marry, Phone Number : 010-654-1234)
Student(Subject : Computer Science, Student ID : 990999)
"""
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요