Skip to content

Latest commit

 

History

History
35 lines (29 loc) · 1.04 KB

README.md

File metadata and controls

35 lines (29 loc) · 1.04 KB

Class Employee

  1. Create a class Employee
class Employee:
    pass

Input SS#

  1. Create a procedure that has an argument of type Employee and inputs their SS# into Employee.ss (substitute you instance variable for Employee here). Your code should validate that a valid SS# is put in.
  2. Create an exception InvalidSocial. In the event that an invalid ss# is typed in raise this exception.
  3. Your code can be pilfered from the exception handling activity, with some modification. The outline is below, where all you need to do is fill in validate
class InvalidSocial(ValueError):
    pass

class Employee:
    pass

def validatess(employee_class):
    check that employee_class.ss is valid
    Anywhere that you find the ss is invalid raise InvalidSocial
    
def getsocial(employee_class):
    employee_class.ss = input("Social: ")
    try
        validatess(employee_class)
    except InvalidSocial:
        print("Invalid SS, please try again\n")
        getsocial(employee_class)

emp = Employee()
getsocial(emp)
print(emp.ss)