I created 2 classes and I need to pass Name, Dept., Birthdate and HireDate from the Employee class to the Date class. I get the month date and year from input prompts. The problem I have is how to get those dates for the employee passed into the date class. The book examples dont really help with this problem much. both of my classes are below and I did do a small class test for each one.
#myEmployee Class
"""This is a Employee Class for a company that tracks Dates"""
class Employee:
def __init__(self):
self._Name = ' ' #Name
self._Dept = ' ' #Department
self._BirthDate = ' '#BirthDate
self._HireDate = ' ' #HireDate
def setName(self, Name):
self._Name = Name
def getName(self):
_Name = raw_input('Please give me your Name. ')
name = []
namlist.append(name)
return self._Name
def setDept(self, Dept):
self._Dept = Dept
def getDept(self):
return self._Dept
def setBirthDate(self, BirthDate):
self._BirthDate = BirthDate
def getBirthDate(self):
Get_Month = raw_input('What month were you born? ')
Get_Day = raw_input('What day were you born? ')
Get_Year = raw_input('What year were you born? ')
return self._BirthDate
def setHireDate(self, HireDate):
self._HireDate = HireDate
def getHireDate(self):
Get_Month = raw_input('What month did you start working? ')
Get_Day = raw_input('What day did you start working? ')
Get_Year = raw_input('What year did you start working? ')
return self._HireDate
def __str__(self):
display = "The Employee with the Name: " + str(self._Name) + " is in the " + str(self._Dept) + " Department. "
display += "The employees birth date is: " + str(self._BirthDate)
display += " and the first day with the company is: " + str(self._HireDate)
return display
#Test class Flight Customer code test
if __name__ == '__main__':
myEmployee = Employee()
myEmployee.getName()
myEmployee.getDept()
myEmployee.getBirthDate()
myEmployee.getHireDate()
print myEmployee
#Date Class
"""This is my Date Class"""
class Date:
def __init__(self):
self._Month= ' '
self._Day = ' '
self._Year = ' '
self.setYear(' ')
def setMonth(self, Month):
self._Month = Month
def getMonth(self):
#pass in get month value here currently just setting it to 5
get_Month = 5
while True:
try:
if 1 <= get_Month and get_Month <= 12:
return self._Month
except ValueError:
print("Please enter only integer numbers! from 1-12")
def setDay(self, Day):
self._Day = Day
def getDay(self):
get_Day = 28
while True:
try:
if 1 <= get_Day and get_Day <= 31:
return self._Day
except ValueError:
print("Please enter only integer numbers! from 1-31")
def setYear(self, Year):
self._Year = Year
def getYear(self):
return self._Year
def __str__(self):
display = "The month is: '" + str(self._Month) + "' and the day is: '"
display += str(self._Day) + "' The Year is: " + str(self._Year)
return display
#Test class Date code test
if __name__ == '__main__':
myDate = Date()
myDate.setMonth('5')
myDate.setDay('15th')
myDate.setYear('2007')
print myDate