-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsimplePark.py
168 lines (150 loc) · 5.37 KB
/
simplePark.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import datetime
from os import system
from colorama import Fore
import random
k = datetime.datetime.now()
a = str(k.date())
system('cls')
print(Fore.GREEN + "\t\t\tPARKING MANAGEMENT SYSTEM\t\t\t")
def main():
system('cls')
print(Fore.GREEN + "PARKING MANAGEMENT SYSTEM")
print(Fore.GREEN + "\n1. Entry\n2. Show\n3. Search\n4. Remove\n5. About")
option = int(input(Fore.GREEN + "Enter your option : "))
switchers = {
1: Entry,
2: Show,
3: Search,
4: Remove,
5: About
}
switchers.get(option)()
def Entry():
system('cls')
print(Fore.GREEN + "\t\t\tENTRY\t\t\t")
print(Fore.GREEN + "1. Car\n2. Bike")
vehicalType = int(input(Fore.GREEN + "Enter your option : "))
switchers = {
1: Car,
2: Bike,
}
switchers.get(vehicalType)()
def Car():
name = input(Fore.GREEN + "Enter Your Name : \n")
vehicalNo = input(Fore.GREEN + "Enter Your Car No : \n")
carModel = input(Fore.GREEN + "Enter Your Car Model : \n")
token = random.randint(100000, 999999)
print("Here is your Secret Token : ")
print(token)
yes = input(Fore.GREEN + "Do you want to go on with this details (Y/N)")
if (yes == 'Y' or yes == 'y' or yes == 'yes' or yes == 'Yes'):
f = open('car.txt', 'a')
f.write(str(token) + ' ' + name.lower() + ' ' + carModel + ' ' + vehicalNo + ' Booking Time: ' + str(k.hour) + ':' + str(k.minute) + '\r\n')
print(Fore.GREEN + "Your Parking has been booked Sucessfully!!\n")
def Bike():
name = input(Fore.GREEN + "Enter Your Name : \n")
vehicalNo = input(Fore.GREEN + "Enter Your Bike No : \n")
bikeModel = input(Fore.GREEN + "Enter Your Bike Model : \n")
token = random.randint(100000, 999999)
print("Here is your Secret Token : ")
print(token)
yes = input(Fore.GREEN + "Do you want to go on with this details (Y/N)")
if (yes == 'Y' or yes == 'y' or yes == 'yes' or yes == 'Yes'):
f = open('bike.txt', 'a')
f.write(str(token) + ' ' + name.lower() + ' ' + bikeModel + ' ' + vehicalNo + ' Booking Time: ' + str(k.hour) + ':' + str(k.minute) + '\r\n')
print(Fore.GREEN + "Your Parking has been booked Sucessfully!!\n")
def Show():
system('cls')
print(Fore.GREEN + "\t\t\tSHOWING DATA\t\t\t")
print(Fore.GREEN + "1. Car\n2. Bike")
showData = int(input(Fore.GREEN + "Enter Vehical Data You want to see : "))
switchers = {
1: showCar,
2: showBike,
}
switchers.get(showData)()
def showCar():
system('cls')
print(Fore.GREEN + "\t\t\tSHOWING CAR DATA\t\t\t")
with open('car.txt', 'r') as f:
cardata = f.read()
print(cardata)
f.close()
def showBike():
system('cls')
print(Fore.GREEN + "\t\t\tSHOWING BIKE DATA\t\t\t")
with open('bike.txt', 'r') as f:
bikedata = f.read()
print(bikedata)
f.close()
def Search():
system('cls')
print(Fore.GREEN + "\t\t\tSEARCH\t\t\t")
print(Fore.GREEN + "1. Car\n2. Bike")
searchData = int(input(Fore.GREEN + "Enter in which slot you want to search : "))
switchers = {
1: searchCar,
2: searchBike,
}
switchers.get(searchData)()
def searchCar():
system('cls')
key = input(Fore.GREEN + "Enter Token : ")
f = open('car.txt', 'r')
for line in f:
line = line.rstrip()
if line.startswith(key):
print(Fore.GREEN + line)
def searchBike():
system('cls')
key = input(Fore.GREEN + "Enter Token : ")
f = open('bike.txt', 'r')
for line in f:
line = line.rstrip()
if line.startswith(key):
print(Fore.GREEN + line)
def Remove():
system('cls')
print(Fore.GREEN + "\t\t\tREMOVE\t\t\t")
print(Fore.GREEN + "1. Car\n2. Bike")
removeData = int(input(Fore.GREEN + "Enter in which slot you want to remove : "))
switchers = {
1: removeCar,
2: removeBike,
}
switchers.get(removeData)()
def removeCar():
system('cls')
key = input(Fore.GREEN + "Enter Token : ")
f = open('car.txt')
tokenline = f.readlines()
for line in tokenline:
line = line.rstrip()
if line.startswith(key):
index = tokenline.index(line + "\n")
tokenline[index] = ""
myFile = open("car.txt", "w")
myFiles = "".join(tokenline)
myFile.write(myFiles)
myFile.close()
def removeBike():
system('cls')
key = input(Fore.GREEN + "Enter Token : ")
f = open('bike.txt')
tokenline = f.readlines()
for line in tokenline:
line = line.rstrip()
if line.startswith(key):
index = tokenline.index(line + "\n")
tokenline[index] = ""
myFile = open("bike.txt", "w")
myFiles = "".join(tokenline)
myFile.write(myFiles)
myFile.close()
def About():
system('cls')
print(Fore.GREEN + "\tPARKING MANAGEMENT SYSTEM\n\n")
print(Fore.GREEN + "A smart vehicle parking system not only helps to look for parking but also saves time.\nBuild in Python 3.9 and used Tkinter Module.\nMade By Sachin Lohar\nCopyright All Rights Reserved\n\n")
enter = input(Fore.GREEN + "Press any number to go Back: ")
main()
main()