Create functions to test the validity of month, day, year, and store these in a separate file called modVerifyDate: isValidMonth isValidDay isValidYear HINT: for testing the day, this method of the CALENDAR module will be useful: monthrange(year, month) Returns weekday of first day of the month and number of days in month, for the specified year and month. Create an employee class The requirements for the class are as follows: Must have at least 4 private attributes/characteristics – one must be an object of type date Must have getter methods for each of the attributes Must have setter methods for each of the attributes Must have an str method to print the object with appropriate labels for each attribute Must have a constructor ( __init__) Must have a method which calculates using date objects If your class is about employees, calculate the number of years worked given the startDate. Store this in a SEPARATE file called modEmployee.py Test the class – put this is a SEPARATE file called testEmployee.py Example of a test program that THOROUGHLY tests ALL of the methods for a Room class NOTE – you may NOT use Room for this! from modRoom import Room r1 = Room("BR160",50,100 ) print("Room 1: ", r1) print("Testing getters for Room 1") idNum = r1.getRmID(); print("ID Number: ", idNum) rmLength = r1.getRmLength(); print("Length ", rmLength) rmWidth = r1.getRmWidth(); print("Width ", rmWidth) rmArea = r1.calcRmArea(); print("Area: ", rmArea) r2 = Room("LI 300", 20, 40) print("\n\nRoom 2: ", r2) print("\nTesting setters for Room 2") r2.setRmID("Hagen123") r2.setRmLength(300); r2.setRmWidth(150) print("Changing r2’s info to Hagen 123, Length 300, Width 150") print(r2) Add the following to the program: #ask the user to enter information for each of the attributes of your class. #ask the user to enter the information related to the date attribute for your class: #Ask the user to enter the year – check for validity #Ask the user to enter the month – check for validity #Ask the user to enter the day – check for validity using the monthrange method #create a new object of your class #print the object
- Create functions to test the validity of month, day, year, and store these in a separate file called modVerifyDate:
isValidMonth
isValidDay
isValidYear
HINT: for testing the day, this method of the CALENDAR module will be useful:
monthrange(year, month)
Returns weekday of first day of the month and number of days in month, for the specified year and month.
Create an employee class
- The requirements for the class are as follows:
- Must have at least 4 private attributes/characteristics – one must be an object of type date
- Must have getter methods for each of the attributes
- Must have setter methods for each of the attributes
- Must have an str method to print the object with appropriate labels for each attribute
- Must have a constructor ( __init__)
Must have a method which calculates using date objects
If your class is about employees, calculate the number of years worked given the startDate.
Store this in a SEPARATE file called modEmployee.py
Test the class – put this is a SEPARATE file called testEmployee.py
- Example of a test program that THOROUGHLY tests ALL of the methods for a Room class
NOTE – you may NOT use Room for this!
from modRoom import Room
r1 = Room("BR160",50,100 ) print("Room 1: ", r1) print("Testing getters for Room 1") idNum = r1.getRmID(); print("ID Number: ", idNum) rmLength = r1.getRmLength(); print("Length ", rmLength) rmWidth = r1.getRmWidth(); print("Width ", rmWidth) rmArea = r1.calcRmArea(); print("Area: ", rmArea)
r2 = Room("LI 300", 20, 40) print("\n\nRoom 2: ", r2) print("\nTesting setters for Room 2") r2.setRmID("Hagen123") r2.setRmLength(300); r2.setRmWidth(150) print("Changing r2’s info to Hagen 123, Length 300, Width 150") print(r2) |
- Add the following to the program:
#ask the user to enter information for each of the attributes of your class.
#ask the user to enter the information related to the date attribute for your class:
#Ask the user to enter the year – check for validity
#Ask the user to enter the month – check for validity
#Ask the user to enter the day – check for validity using the monthrange method
#create a new object of your class
#print the object

Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 7 images









