From f77bee3af22ff61fcdf2b21579211c99efcf4f60 Mon Sep 17 00:00:00 2001 From: nathan <nathan9.baker@live.uwe.ac.uk> Date: Thu, 7 Nov 2024 15:43:01 +0000 Subject: [PATCH] starting to implement screenObj attributes --- main.py | 14 ++++++- src/__init__.py | 4 +- src/{reciptObj.py => bookingObj.py} | 4 +- src/cinemaObj.py | 22 ++++++++--- src/constants.py | 6 +++ src/filmObj.py | 13 ++++++- src/screenObj.py | 58 +++++++++++++++++++++++++++++ 7 files changed, 111 insertions(+), 10 deletions(-) rename src/{reciptObj.py => bookingObj.py} (88%) create mode 100644 src/constants.py create mode 100644 src/screenObj.py diff --git a/main.py b/main.py index b8de312..274f789 100644 --- a/main.py +++ b/main.py @@ -40,7 +40,11 @@ def loginAttempt(username, password): def logout(): pass +def load_cinema(): + pass +def save(): + pass def main() -> None: print("\n\nSTARTING CINEMA MANAGEMENT SYSTEM.\n\n\n\n") @@ -54,7 +58,15 @@ def main() -> None: else: break print("successful login, loading menue...") - # load options and so on... + # load user + # load cinema/s that user is linked to + # display options + # listings: + # get from cinema the listings and display film data. + # create booking: + # create booking obj and display attributes for selection + # save booking to cinema and db + # following code will only execute if run directly from this file. if __name__ == "__main__": diff --git a/src/__init__.py b/src/__init__.py index e4b7b4a..656f668 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -2,8 +2,10 @@ from .staffUser import * from .adminUser import * from .cinemaObj import * from .managerUser import * -from .reciptObj import * +from .bookingObj import * from .reportObj import * +from .screenObj import * +from .constants import * from .dbfunc import * __all__ = ["adminUser", "cinemaObj", "managerUser", "reciptObj", "reportObj", "staffUser", "dbfunc"] \ No newline at end of file diff --git a/src/reciptObj.py b/src/bookingObj.py similarity index 88% rename from src/reciptObj.py rename to src/bookingObj.py index 8004b9f..d315fef 100644 --- a/src/reciptObj.py +++ b/src/bookingObj.py @@ -1,4 +1,4 @@ -class Recipt(object): +class Booking(object): """_summary_ Args: @@ -19,5 +19,5 @@ class Recipt(object): if __name__ == "__main__": # testing - test = Recipt() + test = Booking() print(test) \ No newline at end of file diff --git a/src/cinemaObj.py b/src/cinemaObj.py index 32ca492..93411ec 100644 --- a/src/cinemaObj.py +++ b/src/cinemaObj.py @@ -1,14 +1,26 @@ +from .screenObj import Screen +from .dbfunc import * + class Cinema(object): """_summary_ - + Cinema object is an abstraction of the data stored in the db. + it represents the data of one cinema location. Args: object (_type_): _description_ """ - def addScreen(self): - pass + def __init__(self, id:int=0) -> None: + self.cinema_id = id + self.showings = [] + self.screens = [] - def updateScreen(self): - pass + def create_screen(self): + obj_screen = Screen(capacity=0, sizeH=19,sizeW=16,resolutionH=1080,resolutionW=1920,isIMAX=False) + # add screen to db + + def update_screen(self, screen:Screen, size, resolution, capacity) -> None: + screen.set_capacity(capacity) + screen.set_screen_resolution(resolution) + screen.set_screen_size(size) def operation3(self): pass diff --git a/src/constants.py b/src/constants.py new file mode 100644 index 0000000..1dba46f --- /dev/null +++ b/src/constants.py @@ -0,0 +1,6 @@ +MAX_screen_size:float = 100.0 +MIN_screen_size:float = 0.0 +MAX_screen_resolution:int = 5000 +MIN_screen_resolution:int = 0 +MAX_screen_capacity:int = 500 +MIN_screen_capacity:int = 0 diff --git a/src/filmObj.py b/src/filmObj.py index 1533a47..2563dff 100644 --- a/src/filmObj.py +++ b/src/filmObj.py @@ -4,6 +4,16 @@ class Film(object): Args: object (_type_): _description_ """ + def __init__(self, title:str="") -> None: + self.id = 0 + self.title = title + self.genre = "" + self.rating = "" + self.description = "" + + def __str__(self) -> str: + return f"Film(id={self.id}, title={self.title}, genre={self.genre}, rating={self.rating}, description={self.description})" + def addListing(self): pass @@ -21,4 +31,5 @@ class Film(object): if __name__ == "__main__": # testing test = Film() - print(test) \ No newline at end of file + print(test) + print(test.id) \ No newline at end of file diff --git a/src/screenObj.py b/src/screenObj.py new file mode 100644 index 0000000..497576c --- /dev/null +++ b/src/screenObj.py @@ -0,0 +1,58 @@ +from .constants import MIN_screen_capacity, MAX_screen_capacity, MIN_screen_resolution, MAX_screen_resolution, MIN_screen_size, MAX_screen_size + +class Screen(object): + """_summary_ + + Args: + object (_type_): _description_ + """ + def __init__(self, id:int, capacity:int=0, sizeH:int=0, sizeW:int=0, resolutionH:float=0.0, resolutionW:float=0.0, isIMAX:bool=False) -> None: + self.id = id + self.capacity:int = capacity + self.screenSizeHeight:int = sizeH + self.screenSizeWidth:int = sizeW + self.screenResolutionHeight = resolutionH + self.screenResolutionWidth = resolutionW + self.isIMAX:bool = isIMAX + + def __str__(self) -> str: + return f"Screen(id={self.id}, capacity={self.capacity}, screenSize={self.screenSize}, screenResolution={self.screenResolution}, isIMAX={self.isIMAX})" + + @property + def screenSize(self) -> str: + return f"{self.screenSizeWidth}x{self.screenSizeHeight}m" + @property + def screenResolution(self) -> str: + return f"{self.screenResolutionWidth}x{self.screenResolutionHeight}p" + + # Getters, inherited from Object class + # Setters + def set_capacity(self, value:int) -> None: + if MIN_screen_capacity >= value >= MAX_screen_capacity: + self.capacity = value + else: + # log + print(f"Error; input({value}) out of range {MIN_screen_capacity}-{MAX_screen_capacity}.") + + def set_screen_size(self, height:float, width:float) -> None: + if MIN_screen_size >= height >= MAX_screen_size or MIN_screen_size >= width >= MAX_screen_size: + self.screenSizeHeight = float(height) + self.screenSizeWidth = float(width) + else: + # log + print(f"Error, input values:{height}m, {width}m out of bounds {MIN_screen_size}-{MAX_screen_size}m") + + def set_screen_resolution(self, height:int, width:int) -> None: + if MIN_screen_resolution >= height >= MAX_screen_resolution or MIN_screen_resolution >= width >= MAX_screen_resolution: + self.screenSizeHeight = height + self.screenSizeWidth = width + else: + # log + print(f"Error, input values:{width}x{height}p out of bounds {MIN_screen_resolution}-{MAX_screen_resolution}") + + + +if __name__ == "__main__": + # testing + test = Screen() + print(test) \ No newline at end of file -- GitLab