From ad5ce277e1d5d76073e6407c452178f8949de4a8 Mon Sep 17 00:00:00 2001 From: s444417 Date: Tue, 7 Jun 2022 11:08:47 +0200 Subject: [PATCH] dp changes --- src/components/DP.py | 101 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 86 insertions(+), 15 deletions(-) diff --git a/src/components/DP.py b/src/components/DP.py index e14ff8a..6cd36f6 100644 --- a/src/components/DP.py +++ b/src/components/DP.py @@ -7,12 +7,14 @@ class DP: systemAct = None slotVal = None - + if (lastUserAct == "request" | lastUserAct == "reqmore"): + # TODO policy for user request + return ["Cinema", "select", "", []] - if ((lastUserAct == "hello") | (lastUserAct == "inform") | (lastUserAct == None)): + elif ((lastUserAct == "hello") | (lastUserAct == "inform") | (lastUserAct == None)): # there are no empty slots if not emptySlots: - # generate reservation id + # TODO generate reservation id systemAct = "inform" slotVal = systemSlots # there are empty slots @@ -22,9 +24,6 @@ class DP: slotVal = slot break return ["Cinema", systemAct, slotVal, ""] - elif (lastUserAct == "request" | lastUserAct == "reqmore"): - # TODO policy for user request - return ["Cinema", "select", "", ""] else: systemAct = "repeat" return ["Cinema", systemAct, "", ""] @@ -55,7 +54,7 @@ class DBMock(): def __init__(self): self.shows = { 1: { - "title": "batman", + "title": "Batman", "date": "21.06", "time": 19, "seats": ["a1", "a2", "a3", "a4", "a5", @@ -65,11 +64,12 @@ class DBMock(): "e1", "e2", "e3", "e4", "e5",], "free": ["a1", "a2", "b2", "b3", "b4", + "d1", "d2", "e1", "e2", "e3", "e4",], }, 2: { - "title": "batman", + "title": "Batman", "date": "22.06", "time": 20, "seats": ["a1", "a2", "a3", "a4", "a5", @@ -77,13 +77,14 @@ class DBMock(): "c1", "c2", "c3", "c4", "c5", "d1", "d2", "d3", "d4", "d5", "e1", "e2", "e3", "e4", "e5",], - "free": ["a1", "a2", "a3", - "b2", "b3", "b4", - "d1", "d2", - "e1", "e2", "e3", "e4",], + "free": ["a1", "a2", "a3", "a4", "a5", + "b1", "b2", "b3", "b4", "b5", + "c1", "c2", "c3", "c4", "c5", + "d1", "d2", "d3", "d4", "d5", + "e1", "e2", "e3", "e4", "e5",], }, 3: { - "title": "zorro", + "title": "Zorro", "date": "23.06", "time": 21, "seats": ["a1", "a2", "a3", "a4", "a5", @@ -98,6 +99,76 @@ class DBMock(): "e1", "e2", "e3", "e4", "e5",], } } + + self.reservations = { + 1: { + 'show': 1, + 'seats': ['a3', 'a4', "a5"] + }, + 2: { + 'show': 1, + 'seats': ['b5'] + }, + 3: { + 'show': 1, + 'seats': ['d3', 'd4', "d5"] + }, + 4: { + 'show': 1, + 'seats': ['e5'] + }, + 5: { + 'show': 1, + 'seats': ['c1', 'c2', 'c3', 'c4', "c5"] + }, + 6: { + 'show': 3, + 'seats': ['a3', 'a4', "a5"] + }, + 7: { + 'show': 3, + 'seats': ['c1', 'c2', 'c3'] + }, + } - def getShows(self, title = None, time = None, timeInterval = None, date = None): - pass + def getShows(self, title = None, date = None, time = None,): + # title is None + if(title is None): + titles = [] + for e in self.shows: + if (date is not None & time is not None): + if e["date"] == str(date): + if e["time"] == str(time): + titles.append([e["title"], e["date"]]) + elif (date is not None & time is None): + if e["date"] == str(date): + titles.append([e["title"], e["date"]]) + elif (date is None & time is not None): + if e["time"] == str(time): + titles.append([e["title"], e["date"]]) + return set(titles) + # title is not None + elif(title is not None): + if(date is None): + dates = [] + for e in self.shows: + if e["title"] == str(date): + dates.append(e["date"]) + elif(date is not None): + if(time is None): + + + return set(titles) + # time slot is not None + elif(title is None & time is not None & date is None): + titles = [] + for e in self.shows: + if e["time"] == str(time): + titles.append(e["title"], e["time"]) + return set(titles) + elif(title is None & time is not None & date is None): + titles = [] + for e in self.shows: + if e["time"] == str(time): + titles.append(e["title"], e["time"]) + return set(titles) \ No newline at end of file