Giter Club home page Giter Club logo

py-cinema-visit's Introduction

Cinema visit

You have opened your own cinema. To have a better idea of what's going on in the cinema you decided to keep a record of events in the cinema. For this purpose you have to create such modules:

  1. In directory app create package cinema. In this package create modules:

    • bar.py - inside this module create CinemaBar class that describes work of cinema bar. This class should have only one static method sell_product, that takes product - name of the product that customer wants and customer - Customer instance, that means customer. This method prints what product and to whom cinema sold.
    cb = CinemaBar()
    customer = Customer("Bob", "popcorn")
    cb.sell_product(customer=customer, product=customer.food)
    # Cinema bar sold popcorn to Bob.
    • hall.py - inside this module create CinemaHall class that describes actions during the movie session. Its constructor takes and stores number - number of the hall in cinema. This class should have only one method movie_session, that takes movie_name, customers - list of a customers (Customer instances), cleaning_staff - cleaner (Cleaner instance). This method prints about movie start, calls customers method watch_movie, prints about movie end, calls cleaner method clean_hall.
  2. In directory app create package people. In this package create modules:

    • customer.py - inside this module create Customer class, its constructor takes and stores name, food - food that customer wants to buy in cinema bar. This class should have only one method watch_movie, this method takes movie and prints what movie customer is watching.
    bob = Customer(name="Bob", food="popcorn")
    bob.watch_movie(movie="Madagascar")
    # Bob is watching "Madagascar".
    • cinema_staff - inside this module create Cleaner class, its constructor takes and stores name. This class should have only one method clean_hall, this method takes hall_number - number of hall that cleaner have to clean and prints that cleaner is cleaning that hall.
    anna = Cleaner(name="Anna")
    anna.clean_hall(hall_number=5)
    # Cleaner Anna is cleaning hall number 5.

In the module main.py you have to import all this classes. Classes should be imported by absolute path, that starts with 'app.' with keyword 'from'. Write a function cinema_visit that takes movie_name, customers - a list of customers, elements are dicts with 'name' and desired 'food' of a customer, cleaning_staff - name of the cleaner, that will clean the hall after movie session.

This function should make Customers instances, instance of CinemaHall and CinemaBar, instance of Cleaner. First, cinema bar should sell food to customers, then cinema hall should make a movie session and finally cleaner cleans cinema hall.

Example:

customers = [
    {"name": "Bob", "food": "Coca-cola"},
    {"name": "Alex", "food": "popcorn"}
]
hall_number = 5
cleaner_name = "Anna"
movie = "Madagascar"
cinema_visit(customers=customers, hall_number=5, cleaner="Anna", movie="Madagascar")
# Cinema bar sold Coca-cola to Bob.
# Cinema bar sold popcorn to Alex.
# "Madagascar" started in hall number 5.
# Bob is watching "Madagascar".
# Alex is watching "Madagascar".
# "Madagascar" ended.
# Cleaner Anna is cleaning hall number 5.

py-cinema-visit's People

Contributors

masterpieceelbow avatar abnormaltype avatar danylott avatar ivanramyk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.