-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIOClasses.py
More file actions
95 lines (80 loc) · 2.79 KB
/
Copy pathIOClasses.py
File metadata and controls
95 lines (80 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# ---------------------------------------------------------- #
# Title: IO Classes
# Description: A module of IO classes
# ChangeLog (Who,When,What):
# RRoot,1.1.2030,Created started script
# ---------------------------------------------------------- #
if __name__ == "__main__":
raise Exception("This file is not meant to ran by itself")
else:
import DataClasses as DC
class EmployeeIO:
""" A class for performing Employee Input and Output
methods:
print_menu_items():
print_current_list_items(list_of_rows):
input_employee_data():
changelog: (When,Who,What)
RRoot,1.1.2030,Created Class:
"""
@staticmethod
def print_menu_items():
""" Print a menu of choices to the user """
print('''
Menu of Options
1) Show current employee data
2) Add new employee data.
3) Save employee data to File
4) Exit program
''')
# print() # Add an extra line for looks
@staticmethod
def input_menu_options():
""" Gets the menu choice from a user
:return: string
"""
choice = str(input("Which option would you like to perform? [1 to 4] - ")).strip()
print() # Add an extra line for looks
return choice
@staticmethod
def print_current_list_items(list_of_rows: list):
""" Print the current items in the list of Employee rows
:param list_of_rows: (list) of rows you want to display
"""
print("******* The current employees are: *******")
for row in list_of_rows:
print(str(row.employee_id)
+ ","
+ row.first_name
+ ","
+ row.last_name)
print("*******************************************")
#print() # Add an extra line for looks
@staticmethod
def input_employee_data():
""" Gets data for a employee object
:return: (employee) object with input data
"""
while True:
employee_id = (input("What is the employee Id? - ").strip())
if (employee_id.isnumeric()):
break
else:
print("IDs must be numbers")
while True:
first_name = str(input("What is the employee First Name? - ").strip())
if (not first_name.isnumeric()):
break
else:
print("Names cannot be numbers")
while True:
last_name = str(input("What is the employee Last Name? - ").strip())
if (not last_name.isnumeric()):
break
else:
print("Names cannot be numbers")
try:
emp = DC.Employee(employee_id,first_name,last_name)
except Exception as e:
print(e)
return emp