Skip to content

Commit

Permalink
Update oop.py
Browse files Browse the repository at this point in the history
  • Loading branch information
CoreyMSchafer authored Aug 28, 2017
1 parent a211970 commit 1b74fd2
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions Object-Oriented/3-Class-Static-Methods/oop.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,44 @@ def fullname(self):
def apply_raise(self):
self.pay = int(self.pay * self.raise_amt)

emp_1 = Employee('Corey', 'Schafer', 50000)
emp_2 = Employee('Test', 'Employee', 60000)

print(Employee.raise_amt)
print(emp_1.raise_amt)
print(emp_2.raise_amt)

@classmethod
def set_raise_amt(cls, amount):
cls.raise_amt = amount

@classmethod
def from_string(cls, emp_str):
first, last, pay = emp_str.split('-')
return cls(first, last, pay)

@staticmethod
def is_workday(day):
if day.weekday() == 5 or day.weekday() == 6:
return False
return True


# emp_str_1 = 'John-Doe-70000'
# emp_str_2 = 'Steve-Smith-30000'
# emp_str_3 = 'Jane-Doe-90000'

# first, last, pay = emp_str_1.split('-')
emp_1 = Employee('Corey', 'Schafer', 50000)
emp_2 = Employee('Test', 'Employee', 60000)

# new_emp_1 = Employee(first, last, pay)
# new_emp_1 = Employee.from_string(emp_str_1)
Employee.set_raise_amt(1.05)

# print(new_emp_1.email)
# print(new_emp_1.pay)
print(Employee.raise_amt)
print(emp_1.raise_amt)
print(emp_2.raise_amt)

emp_str_1 = 'John-Doe-70000'
emp_str_2 = 'Steve-Smith-30000'
emp_str_3 = 'Jane-Doe-90000'

first, last, pay = emp_str_1.split('-')

#new_emp_1 = Employee(first, last, pay)
new_emp_1 = Employee.from_string(emp_str_1)

print(new_emp_1.email)
print(new_emp_1.pay)

# import datetime
# my_date = datetime.date(2016, 7, 10)
import datetime
my_date = datetime.date(2016, 7, 11)

# print(Employee.is_workday(my_date))
print(Employee.is_workday(my_date))

0 comments on commit 1b74fd2

Please sign in to comment.