Reputation: 43
I want to be able to make it that if the description of the persons problem includes needing a new password, that it will replace the IT support response with a new generated password (haven't created that class yet so for now, I just want to be sure I can print that it will do that). Please ignore the autoAssign method/ticket counter stuff for now.
For the class callPassword
, I don't want to insert any data into newPassword, I just want it to replace the ticketResponse with "New password generated" if the issue description mentions wanting to change the password. But I can't figure out what I'm doing wrong here, have spent 2 days on it (very beginner)
I keep getting :
t3P = callPassword()
self.tc = self.ticketCreation()
AttributeError: 'callPassword' object has no attribute 'ticketCreation'
Code:
class ticket(object):
counter = 2000
def __init__(self):
self.name = 'Ticket'
self.tc = self.ticketCreation()
self.sr = self.supportResponse()
self.pc = self.callPassword()
class ticketCreation(ticket):
def __init__(self, creatorName, staffID, email, issueDescription):
self.creatorName = creatorName
self.staffID = staffID
self.email = email
self.issueDescription = issueDescription
ticket.counter += 1
self.ticketNumber = ticket.counter
def displayTicket(self):
ticket_info = []
ticket_info.append(self.ticketNumber)
ticket_info.append(self.creatorName)
ticket_info.append(self.staffID)
ticket_info.append(self.email)
ticket_info.append(self.issueDescription)
if self.creatorName == "":
print("Ticket Creator: Not Specified")
else:
print("Ticket Creator: " + str(ticket_info[1]))
if self.staffID == "":
print("--STAFF ID REQUIRED TO SUBMIT TICKET--")
return
else:
print("Staff ID: " + str(ticket_info[2]))
if self.email == "":
print("Email Address: Not Specified")
else:
print("Email Address: " + str(ticket_info[3]))
if self.issueDescription == "":
print("--DESCRIPTION OF YOUR ISSUE IS REQUIRED TO SUBMIT TICKET--")
return
else:
print("Description: " + str(ticket_info[4]))
def autoAssign(self):
if self.staffID == "" or self.issueDescription == "":
print("TICKET NOT CREATED\nTicket Number: N/A")
return
else:
print("Ticket Number: " + str(self.ticketNumber))
class supportResponse(ticket):
def __init__(self, ticketResponse):
self.ticketResponse = ticketResponse
def respond(self):
if self.ticketResponse == "":
print("Response: Not Yet Provided")
else:
print("Response: " + self.ticketResponse)
def resolve(self):
if self.ticketResponse == "":
print("Ticket Status: Open")
else:
print("Ticket Status: Closed")
def reopenStatus(self):
print("Ticket Status: Reopened")
class callPassword(ticket):
def newPassword(self):
if "change password" in ticketCreation.issueDescription:
supportResponse.ticketResponse = "New password generated"
print(supportResponse.ticketResponse)
t1 = ticketCreation("Inna", "INNAM", "[email protected]", "My monitor stopped working")
t1R = supportResponse("sucks")
t2 = ticketCreation("", "MARIAH", "", "Request for video camera to conduct webinars")
t2R = supportResponse("")
t3 = ticketCreation("Joel", "JOELS", "", "change password")
t3P = callPassword()
print("\nPrinting Tickets:\n")
t1.autoAssign()
t1.displayTicket()
t1R.respond()
t1R.resolve()
print()
t2.autoAssign()
t2.displayTicket()
t2R.respond()
t2R.resolve()
print()
t3.autoAssign()
t3.displayTicket()
t3P.newPassword()
t3R.resolve()
Upvotes: 0
Views: 12706
Reputation: 17291
In the ticket
class you are trying to assign new instance attributes from methods that don't exist.
Try removing the self
from the assignments in the ticket
constructor.
Like this:
class ticket(object):
counter = 2000
def __init__(self):
self.name = 'Ticket'
self.tc = ticketCreation() # ticketCreation constructor has parameters.
self.sr = supportResponse() # supportResponse class does too
self.pc = callPassword()
Upvotes: 1