-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgeektrust.py
39 lines (27 loc) · 1.01 KB
/
geektrust.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
from Constants import Constants
import sys
from Apartment import Apartment
def get_commands_and_arguments(text):
arguments = []
splited_text = text.split(' ')
command_name = splited_text[0]
if command_name != Constants.BILL:
arguments = splited_text[1:]
return command_name, arguments
def main():
input_file = sys.argv[1]
with open(input_file) as fp:
Lines = fp.readlines()
for line in Lines:
command_name, arguments = get_commands_and_arguments(line)
if command_name == Constants.ALLOT_WATER:
apartment_object = Apartment(int(arguments[0]), arguments[1])
elif command_name == Constants.ADD_GUESTS:
apartment_object.add_guests(int(arguments[0]))
else:
apartment_object.calculate_billings()
total_water_consumption = apartment_object.total_water_consumption
bill = apartment_object.total_bill
print(total_water_consumption, bill)
if __name__ == "__main__":
main()