def main(): emp_name1 = '' emp_salary1 = 0 emp_year1 = 0 sentinel = 0 emp_name1 = input('Enter name: ') emp_salary1 = float(input('Enter salary: ')) emp_year1 = float(input('Enter years of service: ')) employee1 = Employee(emp_name1, emp_salary1, emp_year1) print(employee1.__str__()) print('') while sentinel != 3: sentinel = int( input( 'Enter 1 to change salary, 2 to change years of service, 3 to exit: ' )) if sentinel == 1: salary = float(input('Enter new salary: ')) employee1.setSalary(salary) elif sentinel == 2: years = float(input('Enter new years of service: ')) employee1.setYears(years) print(employee1.__str__()) print('Monthly pension payout: ', employee1.pension())
def main(): # 数据 people01 = Employee('Susan Meyers', '47899', 'Accouting', 'Vice President') people02 = Employee('Mark John', '39119', 'IT', 'Programmer') people03 = Employee('Joy Rogers', '81774', 'Manufacturing', 'Engineer') print(people01.__str__() + '\n') print(people02.__str__() + '\n') print(people03.__str__())
def __str__(self): """ Returns the object's data in a string. """ return Employee.__str__(self) + "Title: %s\nBonus: %s\n" %\ (self.title, self.bonus)
def __str__(self): #Converts a manager object into a string that lists out the Employee and Manager class attributes return (Employee.__str__(self)+ "\n** Manager Properties:\n** Title:.....%s\n** Bonus:.....%s" % (self.title,str(self.bonus)))
def __str__(self): """ print manager object""" return Employee.__str__(self) + "%s\n%.2f\n" % (self.title, self.bonus)
def __str__(self): return Employee.__str__(self) + ", title: " + self.title + ", bonus: " + str(self.bonus)
def __str__(self): return Employee.__str__(self) + '\nHours worked: ' + str(self.hours_worked) + '\nHourly rate: ' + \ str(self.hourly_rate) + '\nTotal pay: \xe2\x82\xac' + str(self.total_pay())
def __str__(self): return Employee.__str__(self) + f" Title: {self.SSN} Annual Bonus: {self.salary}"
def __str__(self): return Employee.__str__(self) + "\nThe title of the manager is %s and the annual bonus is %d" % (self.title, self.annualBonus)
def __str__(self): """ String output method with Employee object string method combined with Manager data. """ return Employee.__str__(self) + "\nThe title of the manager is %s and the annual bonus is %d" % (self.title, self.annualBonus)