Employee Parsing

Published by Joshua Señoron in

In the class Employee, implement the instance attributes as firstname, lastname and salary.

Create the method from_string() which parses a string containing these attributes and assigns them to the correct properties. Properties will be separated by a dash.

Examples

emp1 = Employee("Mary", "Sue", 60000)
emp2 = Employee.from_string("John-Smith-55000")
emp1.firstname ➞ "Mary"

emp1.salary ➞ 60000

emp2.firstname ➞ "John"

emp2.salary ➞ 55000

Notes

  • The salary is an integer.
  • Check the Resources for some helpful tutorials on how to do this.
Watch a quick demo on how Edabit works.