Code Monkey home page Code Monkey logo

streaming-guide's Introduction

Project 10

First, define a class named Movie that has four data members: _title, _genre, _director, and _year. It should have:

  • an initializer that takes as arguments the title, genre, director, and year (in that order) and assigns them to the data members. The year is an integer and the others are strings.
  • "getter" methods for each of the data members (get_title, get_genre, get_director, and get_year).

Next define a class named StreamingService that has two data members: _name and _catalog. The catalog is a dictionary of Movie objects, with the titles as the keys and the Movie objects as the corresponding values (you can assume there aren't any Movies with the same title). The StreamingService class should have:

  • an initializer that takes the name as an argument, and assigns it to the _name data member. The catalog data member should be initialized to an empty dictionary.
  • getter methods for each of the data members (get_name and get_catalog).
  • a method named add_movie that takes a Movie object as an argument and adds it to the catalog.
  • a method named delete_movie that takes a movie title as an argument and if that Movie is in the catalog, removes it.

Lastly, define a class named StreamingGuide that has one data member, _streaming_services, which will be a list of StreamingService objects. It should have:

  • an initializer that takes no arguments and initializes the _streaming_services data member to an empty list.
  • a method called add_streaming_service that takes a StreamingService object as an argument and adds it to the list.
  • a method named delete_streaming_service that takes the name of a streaming service as an argument and if it's in the list, removes it.
  • a method named where_to_watch that takes a movie title as an argument and returns a list. Element 0 of the list is a string that is the concatenation of the name and year of the movie (with the year in parentheses), with the rest of the list being the names of streaming services showing that movie. For example, the list that is returned might look like this: ['King Kong (1933)', 'HBO Max', 'epix', 'Kanopy']. If the movie is not available on any of the StreamingServices, the method should return None.

So a StreamingGuide will have a list of StreamingServices, and a Streaming Service will have a dictionary of Movies. The where_to_watch method needs to use this nested information to determine which StreamingServices, if any, have the desired movie available.

Here's a simple example of how your code might be used:

movie_1 = Movie('The Seventh Seal', 'comedy', 'Ingmar Bergman', 1957)
movie_2 = Movie('Home Alone', 'tragedy', 'Chris Columbus', 1990)
movie_3 = Movie('Little Women', 'action thriller', 'Greta Gerwig', 2019)
movie_4 = Movie('Galaxy Quest', 'historical documents', 'Dean Parisot', 1999)

stream_serv_1 = StreamingService('Netflick')
stream_serv_1.add_movie(movie_2)

stream_serv_2 = StreamingService('Hula')
stream_serv_2.add_movie(movie_1)
stream_serv_2.add_movie(movie_4)
stream_serv_2.delete_movie('The Seventh Seal')
stream_serv_2.add_movie(movie_2)

stream_serv_3 = StreamingService('Dizzy+')
stream_serv_3.add_movie(movie_4)
stream_serv_3.add_movie(movie_3)
stream_serv_3.add_movie(movie_1)

stream_guide = StreamingGuide()
stream_guide.add_streaming_service(stream_serv_1)
stream_guide.add_streaming_service(stream_serv_2)
stream_guide.add_streaming_service(stream_serv_3)
stream_guide.delete_streaming_service('Hula')
search_results = stream_guide.where_to_watch('Little Women')

Please name your program file streaming_guide.py.

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.