Question: Write a program to create a Person class. It MUST work with the testPerson.py shown below. Person -idNum: integer -firstName: String -lastName: String -birthDate: Date

Write a program to create a Person class. It MUST work with the testPerson.py shown below.

Person

-idNum: integer

-firstName: String

-lastName: String

-birthDate: Date

<>Person(id:Integer, fName: String, lName: String, birthDate: Date)

+str (void): String #NOTE must print the first and last name on one line, and on the next line # the date should bevin this format: Jan 4, 2012 # hint use the strftime method to create the string for the date

+getIdNum( ): Integer

+getFirstName(): String

+getLastName(): String +getBirthDate(): Date

+setIdNum(newID: integer):void

+setFirstName(newFirstName:String): void

+setLastName(newLastName:String): void +setBirthDate(newBirthDate: Date): void

testPerson.py

from modPerson import Person

from datetime import * p1 = Person(111,Joe, Jones, date(2010,1,1) ) p2 = Person(222,Sally, Smith, date(1990, 9, 30) ) print(Person 1: , p1) print(Testing getters for Person 1)

idNum = p1.getIdNum(); print(ID Number: , idNum) fName = p1.getFirstName(); print(First name: , fName) lName = p1.getLastName(); print(Last name: , lName) bDay = p1.getBirthDate( ); print(Birthdate: , bDay)

print(Person 2: , p2) print( Testing setters for Person 2)

p2.setIdNum(123) p2.setFirstName(Joseph) p2.setLastName(Johnson) p2.setBirthDate( date(2000,10,31)) print(After changing p2s first name to Joseph, last name to Johnson, and birthdate to 10/31/2000) print(p2)

Add the following to the testPerson.py program:

#ask the user to enter an id, first name, last name #Ask the user to enter the year of their birth check for validity #Ask the user to enter the month of their birth check for validity #Ask the user to enter the day of their birth check for validity using the monthrange method #create a new object of type Person #print the object

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!