Skip to content

CSCI156/CSCI156-Activity-16

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

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)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published