0
以下のコードは、私のgive_raiseメソッドで文字列をintに変換しようとしています。私はそれが多分私が行方不明のシンプルなものだと知っていますが、私は困惑しています。文字列をintに変換し、そのボーナスを年間給与合計に加算する正しい構文は何ですか?Pythonで文字列をIntに変換する
class Employee():
"""Stores an employee's data"""
def __init__(self, first_name, last_name, annual_salary):
"""Employee values"""
self.first_name = first_name
self.last_name = last_name
self.annual_salary = annual_salary
def give_raise(self, annual_salary = 40000):
"""Sets a default salary with the option to add more"""
choice = input("Do you want to add a bonus to the annual salary of more than 5000 dollars? y\n")
if choice == 'n':
annual_salary += 5000
else:
bonus = input("Please enter your bonus amount: ")
int(bonus)
annual_salary + bonus = annual_salary
print(annual_salary)
my_Employee = Employee('Harry', 'Scrotum', 40000)
my_Employee.give_raise()
ありがとうございました!完璧に働いた。今度は演習のパート2に、テストケースを書く –