#! /usr/bin/env python

class Person:
    nation = 'A nation' #nation은 속성
    
    def greeting(self): #class안에 들어있는 함수를 메소드라고한다
        print('Hi')
    def printNation(self):
        print(self.nation)

    def changeNation(self, country):
        self.nation = country

yune = Person() #Person이란 클래스의 instance이다.
yune.greeting() #
yune.printNation()
yune.changeNation('Korea')

########
#class예제

class Person:
    nation = 'A nation'
    def greeting(self):
        print(('(method)greeting:'), 'Hi')
    def hi1(self): #self에 yune이 들어간다 #자기자신을 의미
        self.greeting #자기자신의 greeting
    def hi2(self):
        greeting() #함수의 greeting으로 간다
def greeting(): #네글잘 띄어쓰기 없으니까 
    print('(funciton)greeting:', 'Hello!')
yune = Person() #인스턴스 생성
yune.greeting() #greeting이라는 메소드 실행 #method(greeting) hello! 출력
print()
yune.hi1() #hi1이 실행됨
yune.hi2()
 
class Person:
    def __init__(self, in_nation):
        self.nation = in_nation
    def showNation(self):
        print(self.nation)

yune = Person('Korea')
yune1 = Person('AAA')

#상속
class Cat:
    def __init__(self):
        self.sleepy = True
 
   def showSleepy(self):
        print(self.sleepy)

    def snack(self):
        print('myeo~')

class KoShort(Cat):
    def snack(self):
        print('야옹~')
catcat = Cat()
catcat.snack()
print(catcat.sleepy, end ='\n\n')

minyong = KoShort()
minyong.snack()
print(minyong.sleepy)

#비공개 속성
class Cat:
    def snack(self):
        print('myeo!')

class KoShort(Cat):
    def setAge(self, Age):
        self.__age = Age
        print('set age to', Age)
    def showAge(self):
        print(self.__age, 'years old.')
    def snack(self):
        print('야옹~')

minyong = KoShort()
minyong.setAge(7)
minyog.snack()
minyong.showAge()
print(minyong.__age) #오류 난다 #비공개속성이라
print(minyong.__age)
