This is a python Programming Fix this issue: -2 no attribute of type date (year was integer) -2 isValidDay function: crashes if user enters a letter -2 test program missing asking user to enter info...



This is a python Programming




Fix this issue:


-2 no attribute of type date


(year was integer)


-2 isValidDay function: crashes if user enters a letter


-2 test program missing asking user to enter info for person.



=====================================================


This is a three program code:


ModPerson


modVerifyDate


TestPerson



=========================



Mod Person Code:



from datetime import date


class Person:


  def __init__(self,tmpSSN='000-00-0000',tmpLastName='Desmond',tmpFirstName='Nduka',birthYr=1996):


    self.__personTuple = (tmpSSN,tmpLastName,tmpFirstName,birthYr)



  def __str__(self):


    temp = ""


    temp += "Social Security Number: " + str(self.__personTuple[0])+'\n'\


    + "Last Name: " + str(self.__personTuple[1]) + '\n'+\


    "First Name: " + str(self.__personTuple[2])+'\n'+"Birth Date: " + \


    str(self.__personTuple[3])


    return temp




  def computeAge(self):


    curAge = date.today().year - self.__personTuple[3]


    return curAge



  def getFirstName(self):


    return self.__personTuple[2]



  def getLastName(self):


    return self.__personTuple[1]



  def getSSN(self):


    return self.__personTuple[0]



  def getBirthYear(self):


    return self.__personTuple[3]



  def setLastName(self,newLastName):


    curSSN = self.__personTuple[0]


    curfName = self.__personTuple[2]


    curBy = self.__personTuple[3]


    self.__personTuple = (curSSN,newLastName,curfName,curBy)



  def setFirstName(self,newFirstName):


    curSSN = self.__personTuple[0]


    curLName = self.__personTuple[1]


    curBy = self.__personTuple[3]


    self.__personTuple = (curSSN,curLName,newFirstName,curBy)



==============================================================



modVerify Date:




from datetime import *


from calendar import *


def isValidYear(year):


  #year is any string


  if year.isdigit() and int(year) > MINYEAR and \


      int(year) <>


    return True


  return False



def isValidMonth(month):


  #month is any string


  if month.isdigit() and int(month) >= 1 \


      and int(month) <=>


    return True


  return False



def isValidDay(year, month, theirDays):


  res = monthrange(year, month)


  validNumDays = res[1]


  if theirDays >= 1 and theirDays <=>


    return True


  return False



=========================================



testPerson Code:




from modPerson import Person


from modVerifyDate import *



print("CLASS PERSON:")


p1 = Person(123121234,'Barack','Obama',1952)


p2 = Person()


print('p1:','\n',p1)


print('p2:','\n',p2)


print('The age for p1 is: ','\n',p1.computeAge())


print('The age for p2 is: ','\n',p2.computeAge())



print("TESTING THE GETTER METHOD FOR P1:")


print('First name for p1 is: ',p1.getFirstName())


print('p1 Last Name: ',p1.getLastName())


print('p1 SSN: ',p1.getSSN())


print('p1 Birthyear: ', p1.getBirthYear())



print("TESTING THE GETTER METHOD FOR P2:")



print('First name for p2: ',p2.getFirstName())


print('p2 Last Name: ',p2.getLastName())


print('p2 SSN: ',p2.getSSN())


print('p2 Birthdate: ',p2.getBirthYear())



print('TESTING SETTER METHOD FOR P1')


p1.setLastName('Joe')



p1.setFirstName('Biden')


print(p1)



print('TESTING SETTER METHOD FOR P2')


p2.setLastName('Kamala')



p2.setFirstName('Harris')


print(p2)

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here