I need help figuring out what is wrong with my code. class employee: def __init__(self, name, age, rank_ID): self.name = name self.age = age self.rank_ID = rank_ID def is_higher_rank(self, employee): if self == employee: return "These employees are both the same rank!" elif self.rank_ID < employee.rank_ID: return self.name + " is senior rank than " + employee.name + "!" else: return employee.name + " is senior in rank than " + self.name + "!" def __eq__(self, employee): return self.rank_ID == employee.rank_ID def __repr__(self): rep = ("Employee Name: " + str(self.name) + "\n" + "Age: " + str(self.age) + "\n" + "ID: " + str(self.rank_ID) + "\n") return rep employee1 = employee("Michael", 45, 12345) employee2 = employee("Dwight", 40, 23456) employee3 = employee("Pam", 30, 34567) employee4 = employee("Jim", 35, 12345) def test_is_higher_rank(): assert employee1.is_higher_rank(employee4) == 'These employees ''These employees are both the same rank!', "Should be the same" assert employee3.is_higher_rank(employee2) == 'Dwight is senior in rank than Pam!', \ "Should be the Dwight senior Pam" assert employee4.is_higher_rank(employee2) == 'Jim is senior in rank than Dwight!', \ "Should be Jim senior Dwight" assert employee4.is_higher_rank(employee3) == 'Jim is senior in rank than Pam!', \ "Should be Jim senior Pam" print() print(employee1) print(employee2) print(employee3) print(employee4) print(employee1.is_higher_rank(employee4)) print(employee2.is_higher_rank(employee2)) print(employee3.is_higher_rank(employee2)) print(employee4.is_higher_rank(employee3)) test_is_higher_rank() print("Everything Passed.") print() the above is what I have so far but when i run it through pycharm i get Traceback (most recent call last): File "C:/Users/thepe/PycharmProjects/CPE101Labs/Lab 8/employee.py", line 48, in print(employee1.is_higher_rank(employee4)) AttributeError: 'employee' object has no attribute 'is_higher_rank' WHAT DO

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I need help figuring out what is wrong with my code.

class employee:
def __init__(self, name, age, rank_ID):
self.name = name
self.age = age
self.rank_ID = rank_ID


def is_higher_rank(self, employee):
if self == employee:
return "These employees are both the same rank!"
elif self.rank_ID < employee.rank_ID:
return self.name + " is senior rank than " + employee.name + "!"
else:
return employee.name + " is senior in rank than " + self.name + "!"


def __eq__(self, employee):
return self.rank_ID == employee.rank_ID


def __repr__(self):
rep = ("Employee Name: " + str(self.name) + "\n" + "Age: " + str(self.age) + "\n" + "ID: "
+ str(self.rank_ID) + "\n")
return rep


employee1 = employee("Michael", 45, 12345)
employee2 = employee("Dwight", 40, 23456)
employee3 = employee("Pam", 30, 34567)
employee4 = employee("Jim", 35, 12345)


def test_is_higher_rank():
assert employee1.is_higher_rank(employee4) == 'These employees ''These employees are both the same rank!', "Should be the same"
assert employee3.is_higher_rank(employee2) == 'Dwight is senior in rank than Pam!', \
"Should be the Dwight senior Pam"
assert employee4.is_higher_rank(employee2) == 'Jim is senior in rank than Dwight!', \
"Should be Jim senior Dwight"
assert employee4.is_higher_rank(employee3) == 'Jim is senior in rank than Pam!', \
"Should be Jim senior Pam"


print()
print(employee1)
print(employee2)
print(employee3)
print(employee4)
print(employee1.is_higher_rank(employee4))
print(employee2.is_higher_rank(employee2))
print(employee3.is_higher_rank(employee2))
print(employee4.is_higher_rank(employee3))


test_is_higher_rank()
print("Everything Passed.")
print()

 

the above is what I have so far but when i run it through pycharm i get

Traceback (most recent call last):
  File "C:/Users/thepe/PycharmProjects/CPE101Labs/Lab 8/employee.py", line 48, in <module>
    print(employee1.is_higher_rank(employee4))
AttributeError: 'employee' object has no attribute 'is_higher_rank'

 

WHAT DO

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education