This application is a video on-demand streaming service which replicates what Netflix and HBO Max do on the market right now. You can create an account, purchase movies and Premium features, but also rate and like your favourite movies. Let the watch begin!
Firstly, uninstall any streaming service you have installed on your device, because this is what you'll want to use from now on.
Secondly, you can run it with Java 11-19 from Test class and giving it a JSON format file as input.
When it comes to the implementation, I simulated a middleware server which does requests on a database and it responds with a succesful or error output. Every action returns an output generated by the Utiliy class, based on the signal coming from the action. The response then is taken by the middleware and it is given back to the user in JSON format.
There are two types of commands:
-
Change page - you can change the page you are on to any other accesible page
-
On page - you can execute some actions that are possible on the current page
-
Database - you can add/delete movies to/from the database of movies
Every possible command and links can be found in Actions enum or following the following link:
The code is easier to read, because every possible action is written inside the UserActions and AdminActions enums, that implement the Action interface.
I used multiple inheritances, as follows:
-
Account
-
PremiumAccount
-
StandardAccount
-
-
Page - which implements PageFunctions
-
LoginPage
-
LogoutPage
-
RegisterPage
-
HomePageAuth and HomePageNoAuth
-
MoviesPage
-
DetailsPage
-
UpgradesPage
-
-
Observable - class used for the Observer Pattern (notification system)
- Database
-
Observer - abstract class used for the Observer Pattern (notification system)
The PageFunction interface contains methods that are crucial for the site to work properly, so everytime you would like to add a new type of page, you have to implement your own method for linking the pages and the function to set the state of a session. There is a standard implementation for setting the next page in the abstract Page class, but if you want a specific checking before setting the next page, you should override it with your own implementation.
-
Singleton pattern - used for the site connection class, but also for the factories, because more instances of these classes would be useless and would just use memory
-
Factory pattern - used for creating the accounts and each page, so the creation part is decoupled from the logic behind every page, each factory throws an exception if the requested type is not implemented
-
Command pattern - it is actually a watered down version of the Command pattern, because I don't keep track of the actions, but every possible action is stored as a anonymous class in the Actions enum (every action has to implement the abstract function executeAction in Actions enum) and it can be stored in the HashMap of each individual page, so any page can have multiple possible actions that you can set up in that enum
-
Observer pattern -used for notification system that adds a notification to each user when adding or deleting a movie from the database, if the user is subscribed to one of the genres of the added/deleted movie
I plan to implement also Filter patter for better filtering the movie lists.
The main class of the site, SiteConnection, is a Singleton class, so it can be called as many times as you want without being memory heavy. In this class, the input from the user is loaded and a new connection to the database is established, then every action of the user is taken one by one and executed, checking for errors and applying its effect on the database, then it gives a response back to the user, which can be an error or a successful output.
You can also find a Config class which holds different constants for your site, like movie and premium pricing, but also the number of free premium movies an account gets when becoming premium. Tweak them as you like.
You can also add other responses and response codes for the actions if you like to in the Utiliy class.
I also added the unlike action for the user, so it can now unlike a movie that it previously liked. Other actions like this one on the way.
There are things to improve and I want to present them if you want to contribute:
-
More actions and commands for users
-
A hashing system for passwords
-
Easier input for the user
Until then, you can watch some of the best movies like Pistruiatu or Titanic.