Skip to content

Commit

Permalink
Added common starting code for tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey Schafer authored and Corey Schafer committed Mar 25, 2017
1 parent 34653e5 commit dc29fb6
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Starting_Code/calc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

def add(x, y):
"""Add Function"""
return x + y


def subtract(x, y):
"""Subtract Function"""
return x - y


def multiply(x, y):
"""Multiply Function"""
return x * y


def divide(x, y):
"""Divide Function"""
return x / y
46 changes: 46 additions & 0 deletions Starting_Code/employee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

class Employee:
"""A sample Employee class"""

num_of_emps = 0
raise_amt = 1.04

def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay

Employee.num_of_emps += 1

@property
def email(self):
return '{}.{}@email.com'.format(self.first, self.last)

@property
def fullname(self):
return '{} {}'.format(self.first, self.last)

def apply_raise(self):
self.pay = int(self.pay * self.raise_amt)

def __repr__(self):
return "Employee('{}', '{}', {})".format(self.first, self.last, self.pay)


class Manager(Employee):
"""A sample Manager class"""

def __init__(self, first, last, pay, employees=None):
super().__init__(first, last, pay)
self.employees = employees if employees else []

def add_emp(self, emp):
if emp not in self.employees:
self.employees.append(emp)

def remove_emp(self, emp):
if emp in self.employees:
self.employees.remove(emp)

def __repr__(self):
return "Manager('{}', '{}', {}, {})".format(self.first, self.last, self.pay, self.employees)

0 comments on commit dc29fb6

Please sign in to comment.