-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCaseStudyModule.py
84 lines (74 loc) · 2.53 KB
/
CaseStudyModule.py
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
import csv
from datetime import datetime, timedelta, date
#tuple
TeamPositionList = ("C", "1B", "2B", "3B", "SS", "LF", "CF", "RF", "P")
#intro
def menu():
print("=" * 64)
print(" Baseball Team Manager ")
print()
print("CURRENT DATE (YYYY-MM-DD): ", date.today())
GameDate = str(input("GAME DATE (YYYY-MM-DD): "))
if GameDate == "":
menuoptions()
else:
GameDate = datetime.strptime(GameDate, "%Y-%m-%d")
DifferenceOfDays = GameDate-datetime.now()
if DifferenceOfDays <= timedelta(days = 0):
menuoptions()
else:
print("DAYS UNTIL GAME:", DifferenceOfDays.days)
menuoptions()
#menu function
def menuoptions():
print()
print("MENU OPTIONS")
print("1 - Display lineup")
print("2 - Add player")
print("3 - Remove player")
print("4 - Move player")
print("5 - Edit player position")
print("6 - Edit player stats")
print("7 - Exit program")
print()
print("POSITIONS")
print(TeamPositionList[0] + " , " + TeamPositionList[1]+ " , " +TeamPositionList[2]+ " , " +TeamPositionList[3]+ " , " +TeamPositionList[4]+ " , " +TeamPositionList[5]+ " , " +TeamPositionList[6]+ " , " +TeamPositionList[7]+ " , " +TeamPositionList[8])
print()
try:
with open("player_list.csv") as file:
print("File found")
except FileNotFoundError:
print("Team data file could not be found")
print("You can create a new one if you want")
print("=" * 64)
#batting average function
def battingaverage(x,y):
if y > 0:
BattingAverage = x / y
BattingAverage = round(BattingAverage, 2)
BattingAverage = str(BattingAverage)
return BattingAverage
else:
BattingAverage = 0
return BattingAverage
def ErrorCheckerAtBats(x):
while True:
if x < 0:
print("Error, official times at bat can't be less than 0, please try again.")
print()
x = int(input("Official number of at bats: "))
else:
break
def ErrorCheckerHits(x,y):
while True:
if y > x:
print("Error, official at bats can't be greater than number of hits please try again.")
print()
y = int(input("Number of hits: "))
x = int(input("Official number of at bats: "))
elif y < 0:
print("Error, Can't have negative number of hits, please try again.")
print()
y = int(input("Number of hits: "))
else:
break