I'm trying to write an object-oriented program that allows me to enter and store monthly income and bills, and view all data as needed. I can successfully store an object, but when I try to use my view_all function, I get this error:
in view_all print(item.get_month())
AttributeError: 'str' object has no attribute 'get_month'
If you could help me track down this problem I'd be grateful!
# Create a month class
class Month:
# Use __init__ method to initialize the attributes
def __init__(self, month, income, tds, pnm, zia, water):
self.__month = month
self.__income = income
self.__tds = tds
self.__pnm = pnm
self.__zia = zia
self.__water = water
# The set methods accept arguments:
def set_month(self, month):
self.__month = month
def set_income(self, income):
self.__income = income
def set_tds(self, tds):
self.__tds = tds
def set_pnm(self, pnm):
self.__pnm = pnm
def set_zia(self, zia):
self.__zia = zia
def set_water(self, water):
self.__water = water
# The get methods return the data:
def get_month(self):
return self.__month
def get_income(self):
return self.__income
def get_tds(self):
return self.__tds
def get_pnm(self):
return self.__pnm
def get_zia(self):
return self.__zia
def get_water(self):
return self.__water
# The __str__ method return's the object's state as a string
def __str__(self):
return "Month: " + self.__month + \
"\nIncome: " + self.__income + \
"\nTDS: " + self.__tds + \
"\nPNM: " + self.__PNM + \
"\nZia: " + self.__zia + \
"\nWater: " + self.__water
And the main program:
import Month_Class
import pickle
ADD_MONTH = 1
VIEW_ALL = 2
QUIT = 3
FILENAME = 'ruidoso.dat'
def main():
months = load_months()
choice = 0
while choice != QUIT:
choice = get_menu_choice()
if choice == ADD_MONTH:
add_month(months)
elif choice == VIEW_ALL:
view_all(months)
save_months(months)
def load_months():
try:
input_file = open(FILENAME, 'rb')
months_dct = pickle.load(input_file)
input_file.close
except IOError:
month_dct = {}
return month_dct
def get_menu_choice():
print()
print('Menu')
print('------------------')
print("1. Add data for a new month")
print("2. View data for all months")
print('Any other number saves and quits the program!')
print()
choice = int(input('Enter your choice: '))
while choice < ADD_MONTH or choice > QUIT:
choice = int(input('Enter a valid choice: '))
return choice
def add_month(months):
month = input('Enter the name of the month: ')
income = input('Total income for this month: ')
tds = input('TDS Broadband bill total: ')
pnm = input('PNM bill total: ')
zia = input('Zia Natural Gas bill total: ')
water = input('City of Ruidoso bill total: ')
entry = Month_Class.Month(month, income, tds, pnm, zia, water)
if month not in months:
months[month] = entry
print('The entry has been added')
else:
print('That month already exists!')
def save_months(months):
output_file = open(FILENAME, 'wb')
pickle.dump(months, output_file)
output_file.close()
def view_all(months):
for item in months:
print(item.get_month())
print(item.get_income())
print(item.get_tds())
print(item.get_pnm())
print(item.get_zia())
print(item.get_water())
main()
You need to iterate over the dictionary differently
for month, item in months.items():
print(item.get_month())
...
In the view_all method, you must to iterate over dictionary:
for key, item in months.iteritems():
print(item.get_month())
and you got other error in __str__ method of Month class:
"\nPNM: " + self.__PNM + \
the correct is:
"\nPNM: " + self.__pnm + \
Related
I have a problem adding scores to an object with a for loop.
what I'm trying to achieve is this:
enter test num: 1
enter test score: 58
enter test num: 2
etc...
and then print out the three test numbers and the average, but I can't seem to get it to set the test num nor the score.
this is the error I get after tring to add test 1 and test 1 score:
Traceback (most recent call last):
File "d:\pyproj\Lecture 5\Main.py", line 27, in <module>
studentArray()
File "d:\pyproj\Lecture 5\Main.py", line 25, in studentArray s = student.setTestScore(test,score)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: student.setTestScore() missing 1 required positional argument: 'result'
Main.py
from student import student
def studentArray():
classSize = int(input("how big is the class? "))
classList = []
num=0
while not(num == classSize):
firstName = input("\nWhat's the students first name? ");
lastName = input("\nWhat's the students last name? ");
homeAddress = input("\nWhat's the students home address? ");
schoolAddress = input("\nWhat's the students school address? ");
courseName = input("\nWhat course is the students taking? ");
courseCode = input("\nWhat's the course code? ");
classList.append(student(firstName,lastName,homeAddress,schoolAddress,courseName,courseCode));
num+=1
for s in classList:
for i in range(len(classList)):
test = int(input("enter test number: "))
score = int(input("enter test score: "))
s.setTestScore(test,score)
print("\n",s)
studentArray()
studentclass.py:
from Course import Course
class student:
def __init__(self,first, last, home, school,courseName,courseCode):
self.firstName = first
self.lastName = last
self.homeAddress = home
self.schoolAddress = school
self.courseName = courseName
self.courseCode = courseCode
Course(courseName,courseCode)
self.testResults = []
def setTestScore(self,test,result):
if test < 1 | result < 0 | test > 100:
print("Error: Wrong test results.")
else:
self.testResults.append(result)
def average(self):
average = 0;
total = 0;
for result in self.testResults:
total += result
average = total / 3.0;
return average;
def __str__(self):
testAString = ""
for testResult in self.testResults:
testAString += str(testResult) + " "
result = "Student name:\n"+self.firstName + " " + self.lastName+"\n";
result += "Course name:\n"+self.courseName+"\n";
result += "Course Code: "+ self.courseCode+"\n";
result += "Test results:\n"+testAString+"\n";
result += "Average:\n", str(self.average()), "\n";
result += "Home Address:\n"+self.homeAddress+"\n";
result += "School Address:\n"+ self.schoolAddress;
return result;
Courseclass.py:
class Course:
def __init__(self,course,code):
self.course = course
self.code = code
def setCourseName(self,name):
self.course = name
def setCourseCode(self, code):
self.course = code
Issue is you are trying to run setTestScore function without instantiating the class. Either make it a staticmethod or call it from an object
for s in classList:
for i in range(len(classList)):
test = int(input("enter test number: "))
score = int(input("enter test score: "))
s.setTestScore(test,score)
print("\n"+s)
PS: Line
classList = [classSize]
creates a new list and adds classSize to the list as the first element. I assume you want to create a list with size of classSize. You do not need to specify length when creating lists in python.
Also,
testResults = []
this initalization is outside of init, which makes testResults a class variable, means it will be shared within all classes. I would advise you to move it inside init function
Editing upon your edit, you are trying to concat string with a tuple
result += "Average:\n", str(self.average()), "\n";
What you should do is:
result += "Average:\n" + str(self.average()) + "\n";
In python you don't need to end lines with ;
also you need to create an instance of the class and on that instance you can use the class methods
look in the code I added comments on every change
Main.py
from student import student
def studentArray():
classSize = int(input("how big is the class? "))
classList = []
num = 0
while num != classSize:
firstName = input("\nWhat's the students first name? ")
lastName = input("\nWhat's the students last name? ")
homeAddress = input("\nWhat's the students home address? ")
schoolAddress = input("\nWhat's the students school address? ")
courseName = input("\nWhat course is the students taking? ")
courseCode = input("\nWhat's the course code? ")
new_student = student(firstName, lastName, homeAddress, schoolAddress, courseName, courseCode)
classList.append(new_student)
number_of_test = int(input("\nHow many tests did the student had? "))
for i in range(number_of_test):
test = int(input("enter test number: "))
score = int(input("enter test score: "))
new_student.setTestScore(test, score)
num += 1
for s in classList:
print("\n" + str(s))
studentArray()
studentclass.py
from Course import Course
class student:
def __init__(self, first, last, home, school, courseName, courseCode):
self.firstName = first
self.lastName = last
self.homeAddress = home
self.schoolAddress = school
self.courseName = courseName
self.courseCode = courseCode
self.testResults = []
Course(courseName, courseCode)
def setTestScore(self, test, result):
if test < 0 or result < 0 or result > 100:
print("Error: Wrong test results.")
else:
self.testResults.append(result) # append to the list
def average(self):
average = 0
total = 0
for result in self.testResults:
total += result
average = total / 3.0
return str(average) # str the average
def __str__(self):
testAString = ""
for testResult in self.testResults:
testAString += str(testResult) + " " # str the testResult
result = "Student name:\n" + self.firstName + " " + self.lastName + "\n"
result += "Course name:\n" + self.courseName + "\n"
result += "Course Code: " + self.courseCode + "\n"
result += "Test results:\n" + testAString + "\n"
result += "Average:\n" + self.average() + "\n"
result += "Home Address:\n" + self.homeAddress + "\n"
result += "School Address:\n" + self.schoolAddress
return result
There are several issues with your code, most of them involve try to concatenate strings and non string types, as well as a few type errors along the way. You are also using the bitwise | instead of or which are not the same thing.
Starting with your student class:
use the actual or keyword instead of using bitwise |, it may be providing accurate results for some answers but it is not operating in the way you think it is.
in your __str__ method there are a few instances where you are trying to contatenate a string and an int.
in your setTestScores function you want to append the result to the testResults list.
Here is an example fix for those problems:
class student:
testResults = []
def __init__(self,first, last, home, school,courseName,courseCode):
self.firstName = first
self.lastName = last
self.homeAddress = home
self.schoolAddress = school
self.courseName = courseName
self.courseCode = courseCode
Course(courseName,courseCode)
def setTestScore(self,test,result):
if test < 1 or result < 0 or test > 100:
print("Error: Wrong test results.")
else:
self.testResults.append(result)
def average(self):
average = 0
total = 0
for result in self.testResults:
total += result
average = total / 3.0
return average
def __str__(self):
testAString = ""
for testResult in self.testResults:
testAString += str(testResult) + " "
result = "Student name:\n"+self.firstName + " " + self.lastName+"\n"
result += "Course name:\n"+self.courseName+"\n"
result += "Course Code: "+ self.courseCode+"\n"
result += "Test results:\n"+testAString+"\n"
result += "Average:\n" + str(self.average()) +"\n"
result += "Home Address:\n"+self.homeAddress+"\n"
result += "School Address:\n"+ self.schoolAddress
return result
Next you have the studentArray function.
you don't need to specify the size of the classList since lists can be dynamically appended to.
you need to convert your instance to a string before concatenating it with the new line character.
Here is an example fix for that.
def studentArray():
classSize = int(input("how big is the class? "))
classList = []
num=0
while not(num == classSize):
firstName = input("\nWhat's the students first name? ")
lastName = input("\nWhat's the students last name? ")
homeAddress = input("\nWhat's the students home address? ")
schoolAddress = input("\nWhat's the students school address? ")
courseName = input("\nWhat course is the students taking? ")
courseCode = input("\nWhat's the course code? ")
s = student(firstName,lastName,homeAddress,schoolAddress,courseName,courseCode)
classList.append(s)
num+=1
for s in classList:
for i in range(len(classList)):
test = int(input("enter test number: "))
score = int(input("enter test score: "))
s.setTestScore(test,score)
print("\n"+str(s))
Making these adjustments this was the output of your code.
how big is the class? 1
What's the students first name? a
What's the students last name? b
What's the students home address? 10
What's the students school address? 12
What course is the students taking? art
What's the course code? 1
enter test number: 1
enter test score: 88
Student name:
a b
Course name:
art
Course Code: 1
Test results:
88
Average:
29.333333333333332
Home Address:
10
School Address:
12
finally if you want to add more test scores you need add another question that asks how many tests were taken in the class and then iterate based on the response.
num_tests = int(input('how many tests'))
for s in classList:
for i in range(num_tests):
test = int(input("enter test number: "))
score = int(input("enter test score: "))
s.setTestScore(test,score)
class volunteerList:
def __init__ (self, groupName):
self.__vList = []
self.__groupName = groupName
def setGroupName (self, newGroupName):
self.__groupName = newGroupName
def getGroupName (self):
return self.__groupName
def getvList (self):
return self.__vList
def addVolunteer (self, volunteer):
self.getvList().append(volunteer)
def highestHour (self):
details = ""
highestHourList = []
highest = self.__vList[0].getHourContribution()
for volunteer in self.__vList:
hour = volunteer.getHourContribution()
if hour == highest:
highestHourList.append(hour)
elif hour > highest:
highestHourList = [hour]
highest = hour
#highestHourList.append(hour)
if volunteer.getType().lower() == "f":
details = details + "{} - {} years old - flood volunteer".format(volunteer.getName(), volunteer.getAge()) + "\n"
elif volunteer.getType().lower() == "p":
details = details + "{} - {} years old - pandemic volunteer".format(volunteer.getName(), volunteer.getAge()) + "\n"
elif volunteer.getType().lower() == "e":
details = details + "{} - {} years old - earthquake volunteer".format(volunteer.getName(), volunteer.getAge()) + "\n"
elif volunteer.getType().lower() == "t":
details = details + "{} - {} years old - tsunami volunteer".format(volunteer.getName(), volunteer.getAge()) + "\n"
return details
def main ():
groupName = input("Enter your group name: ")
newGroup = volunteerList(groupName)
print ("\n")
choice = menu()
while choice != "0":
if choice == "1":
name = input("Name of volunteer? ")
age = int(input("Age? "))
volunteerType = input("Type of volunteer ('F/P/E/T'): ")
volunteerType = volunteerType.lower()
while volunteerType not in "fpet":
print ("Invalid type! Please enter again!")
volunteerType = input("Type of volunteer ('F/P/E/T'): ")
volunteerType = volunteerType.lower()
hourCont = int(input("Contribution hour? "))
while hourCont <= 0:
print ("Invalid value! Please enter again!")
hourCont = int(input("Contribution hour? "))
newGroup.addVolunteer(volunteer(name, age, volunteerType, hourCont))
print ("... Volunteer has been added successfully.")
print ("\n")
choice = menu()
elif choice == "6":
print ("Volunteer with highest contribution hour:")
print (newGroup.highestHour())
print ("\n)
I'm not sure the code on highestHour() correct or wrong. I was planning to find the highest hour of the volunteer(s). If there are more than 1 highest hour of volunteer (same hour), display everything. My output was only one highest hour of volunteer or display 2 same line of statement instead of the example before.
Wondering how to display all volunteer that are highest hour?
The display sample will be:
a - 36 years old - pandemic volunteer
b - 25 years old - flood volunteer
Here you go:
class volunteer:
def __init__ (self, name, age, type, hourContribution):
self.__name = name
self.__age = age
self.__type = type
self.__hourContribution = hourContribution
def getHourContribution (self):
return self.__hourContribution
class volunteerList:
def __init__ (self, groupName):
self.vList = []
self.__groupName = groupName
def highestHour (self):
highHourList = []
hourList = []
for volunteer in self.vList:
hourList.append(volunteer.getHourContribution())
highest = max(hourList)
for hour in hourList:
if hour == highest:
highHourList.append(hour)
print(highHourList)
new = volunteerList("one")
vol1 = volunteer("", 1, "", 5)
vol2 = volunteer("", 1, "", 10)
vol3 = volunteer("", 1, "", 10)
vol4 = volunteer("", 1, "", 10)
vol5 = volunteer("", 1, "", 1)
new.vList = [vol1, vol2, vol3, vol4, vol5]
new.highestHour()
Alternative highestHour function
def highestHour (self):
highHourList = []
largest = self.vList[0].getHourContribution()
for volunteer in self.vList:
hour = volunteer.getHourContribution()
if hour == largest:
highHourList.append(hour)
elif hour > largest:
highHourList = [hour]
largest = hour
print(highHourList)
Needs some cleaning up, but you get the idea.
I am trying to limit the grab command to only allow 4 items to be in the list at a time as well as for the drop and edit command. I'm trying to add a message that would say invalid if the user enters any number of items that is an invalid number.
def grab(item_list):
item = input("Name: ")
item_list.append(item)
print(item + " was added.\n")
def edit(item_list):
pos = int(input("Number: "))
new_value = input("Updated name: ")
item_list[pos-1] = new_value
print("%s was updated" % (new_value))
def drop(item_list):
number = int(input("Number: "))
item = item_list.pop(number-1)
print(item + " was dropped.\n")
print()
def main():
item_list = ["wooden staff","wizard hat","cloth shoes"]
def grab(item_list):
if len(item_list)==4:
print('Cannot grab more than 4. Drop another item and try again')
return
item = input("Name: ")
item_list.append(item)
print(item + " was added.\n")
def edit(item_list):
pos = int(input("Number: "))
if not (pos-1)in range(len(item_list)):
print(str(pos) + ' not in list, try again')
edit(item_list)
return
new_value = input("Updated name: ")
item_list[pos-1] = new_value
print("Updated item %d with new value %s" % (pos, new_value))
def drop(item_list):
number = int(input("Number: "))
if not (number-1) in range(len(item_list)):
print(str(number) + ' not in list, try again')
drop(item_list)
return
item = item_list.pop(number-1)
print(item + " was dropped.\n")
print()
import sys
import os.path
class Juvenile(object):
def createJuv(self, pop, rate):
self.pop = pop
self.rate = rate
def displayJuvpop(self):
return self.pop
def displayjuvRate(self):
return self.rate
class Adult(object):
def createAd(self, pop, rate, brate):
self.pop = pop
self.rate = rate
self.brate = brate
def displayAdpop(self):
return self.pop
def displayAdRate(self):
return self.rate
def displayBirthrate(self):
return self.brate
class Senile(object):
def createSe(self, pop, rate):
self.pop = pop
self.rate = rate
def displaySepop(self):
return self.pop
def displaySerate(self):
return self.rate
a = Juvenile()
b = Adult()
c = Senile()
`enter code here`pop_model = raw_input("Enter the number of generations: ")
`enter code here`pop_model = int(pop_model)
newjuv = 0
newsen = 0
newadu = 0
def menu():
This = True
while This == True:
print("1) Enter Generation 0 values")
print("2) Display Generation 0 values")
print("3) Run the model")
print("4) Export data")
print("5) Quit")
decision = raw_input("")
if decision == "1":
Gen0values()
elif decision == "2":
display()
elif decision == "3":
run()
elif decision == "4":
export()
elif decision == "5":
sys.exit()
def run():
print("Juvenile" + " " + "Adult" + " " + "Senile")
for i in range(0, pop_model):
newjuv = b.displayAdpop()* b.displayBirthrate()
newsen = b.displayAdpop() * b.displayAdRate()
newadu = a.displayJuvpop() * a.displayjuvRate()
print(i + 1,newjuv, newadu,newsen)
a.displayJuvpop() = newjuv
b.displayAdpop() = newsen
c.displaySepop() = newadu
def Gen0values():
a.createJuv(float(raw_input("Enter the juvenile population: ")), float(raw_input("Enter the Juvenile survival rate: ")))
b.createAd(float(raw_input("Enter the Adult population: ")), float(raw_input("Enter the Adult survival rate: ")), float(raw_input("Enter the birth rate: ")))
c.createSe(float(raw_input("Enter the Senile population: ")), float(raw_input("Enter the Senile survival rate: ")))
menu()
The error is coming up here:
def run():
print("Juvenile" + " " + "Adult" + " " + "Senile")
for i in range(0, pop_model):
newjuv = b.displayAdpop()* b.displayBirthrate()
newsen = b.displayAdpop() * b.displayAdRate()
newadu = a.displayJuvpop() * a.displayjuvRate()
print(i + 1,newjuv, newadu,newsen)
a.displayJuvpop() = newjuv
b.displayAdpop() = newsen
c.displaySepop() = newadu
The error comes up with "Can't assign to function call, line 60". Due to stack overflow's code to text limit, I've removed parts of the program that are irrelevant, like exporting the data and displaying the values.
Ps: This isn't an indentation error, copying and pasting somewhat disrupted it.
Your display*pop() functions return a value, not a variable. You can't assign to that function result. Just assign directly to the attributes:
a.pop = newjuv
b.pop = newsen
c.pop = newadu
I have an employee class which has an init method that reads an employees record in from a file. I also have an employees class which has an init_ method that attempts to read in all of the employee records.
I am having trouble with init for the employees class. Here is my code:
class EmployeeList():
records=[]
def __init__(self):
with open(database) as fp:
emp=employee(fp)
while (emp.id > 0):
print(emp)
self.records.append(emp)
emp=employee(fp)
The print(emp) is there for error checking, it shows that the records are being read in properly. When the EOF is reached, the init method for the employee sets the id to 0 and the name of the employee to "". I have two problems:
After the loop, all of the employees in employees.records are the same - id 0 and blanks for names. I am assuming that that emp is not creating a new instance each time it is called, and so all of the employees are being set to that one instance of emp, the very last one from when EOF is reached.
I doubt my code is "Pythonesque"; suggestions for improvement are welcome.
P.S. database is globally defined to the file name.
The entire code is here, sorry about the length:
class employee:
count = 0
def __init__(self,f=None):
if (f==None): # a user is inputting the employee
self.lastname = input("Employees last name:")
while type(self.lastname)!=type("1"):
print("Your input needs to be a name\n")
self.lastname = input("Employees last name:")
self.firstname = input("Employees first name:")
while type(self.firstname)!=type("1"):
print("Your input needs to be a name\n")
self.firstname = input("Employees first name:")
self.payrate = float(input("Employees pay rate:"))
while type(self.payrate)!=type(0.0):
print("Your input needs to be a pay rate\n")
self.payrate = float(input("Employees pay rate:"))
employee.count = employee.count + 1
self.id = employee.count
else: # the employee is being read in from the database and f is a file pointer
# read in an employee record and return false for end of file.
checkEOF = f.readline().rstrip('\r\n') #check for end of file
if (checkEOF != ""):
employee.id = int(checkEOF)
employee.firstname = f.readline().rstrip('\r\n')
employee.lastname = f.readline().rstrip('\r\n')
employee.payrate = float(f.readline().rstrip('\r\n'))
else:
employee.id = 0
employee.firstname = " "
employee.lastname = " "
employee.payrate = 0.0
def __hash__(self):
return hash(self.id)
def __eq__(self, other):
if isinstance(other, self.__class__):
return self.id == other.id
return NotImplemented
def __str__(self):
return "Employee " + str(self.id) + " is "+self.firstname + " "+self.lastname+" and their pay rate is "+str(self.payrate)+"\n"
def __lt__(self, other):
if (self.lastname < other.lastname):
return True
elif (self.lastname > other.lastname):
return False
else: #same last names
if (self.firstname < other.firstname):
return True
elif (self.firstname > other.firstname):
return False
else: #same names
if (self.id < other.id):
return True
else: # note that ids cannot be the same
return False
def __gt__(self, other):
if (self.lastname > other.lastname):
return True
elif (self.lastname < other.lastname):
return False
else: # Same last names
if (self.firstname > other.firstname):
return True
elif (self.firstname > other.firstname):
return False
else: # Same names
if (self.id > other.id):
return True
else: # note that ids cannot be the same
return False
def payraise(self,payraise):
self.payrate = self.payrate+payraise
def saveemployee(self,fp):
fp.write(str(self.id)+"\n")
fp.write(self.firstname+"\n")
fp.write(self.lastname+"\n")
fp.write(str(self.payrate)+"\n")
class EmployeeList():
records=[]
def __init__(self):
with open(database) as fp:
emp=employee(fp)
while (emp.id > 0):
print(emp)
self.records.append(emp)
emp=employee(fp)
def __str__(self):
employeesprint = ""
for emp in self.records:
employeesprint = employeesprint + str(emp)
return employeesprint
def save(self):
self.records.sort()
with open(database,"w+") as fp:
fp.seek(0)
for emp in self.records:
emp.saveemployee(fp)
def menu():
print("\n")
print(choices[0]+". Add another employee")
print(choices[1]+". Print employees")
print(choices[len(choices)-1]+". Quit")
print("\n")
employees = EmployeeList()
choices = ["A","B","C"]
ch = "N"
while (ch != choices[len(choices)-1]):
menu()
ch=input("Make your choice ")
while not (ch in choices):
menu()
ch=input("Make your choice ")
if (ch == choices[0]):
employees.records.append(employee())
employees.save()
if (ch == choices[1]):
print(employees)
Sample output: You can see the two employees correctly being printed as they are read in:
Employee 1 is jane bob and their pay rate is 1.0
Employee 2 is jim bob and their pay rate is 3.4
A. Add another employee
B. Print employees
C. Quit
Make your choice B
Employee 0 is and their pay rate is 0.0
Employee 0 is and their pay rate is 0.0
your code:
if (checkEOF != ""):
employee.id = int(checkEOF)
employee.firstname = f.readline().rstrip('\r\n')
employee.lastname = f.readline().rstrip('\r\n')
employee.payrate = float(f.readline().rstrip('\r\n'))
else:
employee.id = 0
employee.firstname = " "
employee.lastname = " "
employee.payrate = 0.0
change 'employee' to 'self', 'employee' is the name of the class.