Notice
														
												
											
												
												
													Recent Posts
													
											
												
												
													Recent Comments
													
											
												
												
											
									| 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 | 
| 9 | 10 | 11 | 12 | 13 | 14 | 15 | 
| 16 | 17 | 18 | 19 | 20 | 21 | 22 | 
| 23 | 24 | 25 | 26 | 27 | 28 | 29 | 
| 30 | 
													Tags
													
											
												
												- 자바스크립트 API
 - 카카오프로젝트100
 - 보안뉴스 한줄요약
 - 카카오프로젝트
 - oracle
 - GIT
 - 보안뉴스 요약
 - ES6
 - 깃허브
 - 오라클
 - 보안뉴스
 - 자바스크립트 기본 문법
 - javascript
 - 자바스크립트 jQuery
 - 보안뉴스요약
 - 자바스크립트 node
 - 자바스크립트 element api
 - 자바스크립트
 - python
 - 다크웹
 - 보안뉴스한줄요약
 - 자바스크립트 객체
 - 자바스크립트 prototype
 - 카카오프로젝트 100
 - php
 - Oracle SQL
 - numpy
 - 파이썬
 - oracle db
 - 랜섬웨어
 
													Archives
													
											
												
												- Today
 
- Total
 
FU11M00N
[Python] 파이썬으로 구현한 연봉 인상율 프로그램 본문
- 문제

# Class Method
class Employee:
    raise_amount = 1.1  # 1. 연봉 인상률 클래스 변수
    def __init__(self, first, last, pay):
        self.first = first
        self.last = last
        self.pay = pay
    def apply_raise(self):
        self.pay = int(self.pay * self.raise_amount)
    def full_name(self):
        return '{} {}'.format(self.first, self.last)
    def get_pay(self):
        return '현재 {}의 연봉은 {} 입니다.'.format(self.full_name(), self.pay)
    # 1. 클래스 메소드 데코레이터를 사용하여 클래스 메소드 정의
    @classmethod
    def change_raise_amount(cls, amount):
        # 2. 인상율이 1 보다 작으면 재입력 요청
        while amount < 1:
            print('\n[경고] 인상율은 1보다 작을 수 없습니다.')
            amount = input('[입력] 인상율을 다시 입력하여 주십시요.\n => ')
            amount = float(amount)
        cls.raise_amount = amount
        print('인상율 {}가 적용되었습니다'.format(amount))
emp_1 = Employee('Sanghee', 'Lee', 30000000)
emp_2 = Employee('Minjung', 'Kim', 36000000)
# 연봉 인상 전
print("연봉 인상 전 ==> ")
print(emp_1.get_pay())
print(emp_2.get_pay())
# 연봉 인상율 변경
Employee.change_raise_amount(0.9)
# 연봉 인상
emp_1.apply_raise()
emp_2.apply_raise()
# 연봉 인상 후
print("\n연봉 인상 후 ==> ")
print(emp_1.get_pay())
print(emp_2.get_pay())

'Programming > Python' 카테고리의 다른 글
| [Python]다중 상속 (0) | 2020.11.24 | 
|---|---|
| [Python] 상속, 메소드 오버라이딩 (0) | 2020.11.17 | 
| [Python] 정적 메소드 (0) | 2020.11.17 | 
| [Python] 파이썬 생성자와 소멸자 (0) | 2020.11.10 | 
| [Python] 파이썬 클래스와 메소드 ,객체,변수 (0) | 2020.11.10 | 
			  Comments