2つのクラスを作成し、それらをテストしようとしていますが、次のエラーが発生し、一生の間、何が問題なのかわかりません。
これらのクラスをモジュールとして使用し、ユーザーからの入力を取得して引数を設定するという考え方ですが、今のところ、クラスをテストしているだけです。
エラー
File "./Employees.py", line 38, in <module>
emp1Atr.displayAttributes()
AttributeError: Attribute instance has no attribute 'displayAttributes'
以下のコード
#!/usr/bin/python
class Employee:
'Practice class'
empCount = 0
def __init__(self, salary):
self.salary = salary
Employee.empCount += 1
def displayCount(self):
print "Total Employees %d" % Employee.empCount
def displayEmployee(self):
print "Salary: ", self.salary
class Attribute(Employee):
'Defines attributes for Employees'
def __init__(self, Age, Name, Sex):
def Age(self):
self.Age = Age
def Name(self):
self.Name = Name
def Sex(self):
self.Sex = Sex
def displayAttributes(self):
print "Name: ", self.Name + "\nAge: ", self.Age + "\nSex: ", self.Sex
emp1Sal = Employee(2000)
emp1Atr = Attribute(12, "John", "man")
emp1Sal.displayEmployee()
emp1Atr.displayAttributes()