Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 11 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,18 @@


## Introduction
In this assignment, you will create a simulation of Netflix. The program should allow users to create and manage their accounts and profiles, browse movies, and manage their movies. The program should be designed using object-oriented programming principles.

## Objectives
- Review the concepts of object-oriented programming (OOP) and utilize them correctly
- Familiarize yourself with the concept of Encapsulation
- Learn the difference between Static and Instance variables
- Learn about polymorphism
- Get familiar with Interfaces in java
- Get familiar with UML diagrams
- Use Git for version control and collaborate on a codebase
- Write a report on the assignment
In this assignment,i created an app that is simulation of Netflix.users can manage the information on their profiles and the movies
they watched and search through them , and give them a rating and ....

## Tasks
1. Fork this repository and clone the fork to your local machine. Ensure to create a new Git branch before starting your work
2. Complete the following classes by adding the required parameters and implementing the predefined functions: `Movie`, `User`, `TVShow`, `NetflixService`.
3. In the `runMenu()` function of the `Main` class, Implement an interactive menu in the command line that allows users to use the functionalities of the program.
4. Your menu should allow new Users to create an account by providing a username and a password. Prevent new users from choosing a previously taken username. Authenticate each user before logging in
5. Your program should keep a list of all users (and their favorite or previously seen movies), and all movies.
6. You should use inheritance efficiently for the `Movie` class (Read the comments). It has an attribute more than the `TVShow` class (`length`) which is the length of the movie.
7. Implement the predefined methods in the `NetflixService` class, based on the explanations below:
- `createAccount`: Creates an account for a user with the provided username and password. A unique password should be provided.
- `login`: Performs any needed operations of the login process, if there exists any user with such username and password.
- `logout`: Performs any needed operations of the logout process (exiting from the account), if a user is logged in to their account.
- `searchByTitle`: Searches among all the movies by the provided title. Returns an arraylist of the found movies.
- `searchByGenre`: Searches among all the movies by the provided genre. Returns an arraylist of the found movies.
- `searchByReleaseYear`: Searches among all the movies by the provided release year. Returns an arraylist of the found movies.
8. Implement the predefined methods in the `User` class, based on the explanations below:
- `searchByTitle`: Searches among the user's favorite or previously seen movies, by the provided title. Returns an arraylist of the found movies.
- `searchByGenre`: Searches among the user's favorite or previously seen movies, by the provided genre. Returns an arraylist of the found movies.
- `searchByReleaseYear`: Searches among the user's favorite or previously seen movies, by the provided release year. Returns an arraylist of the found movies.
- `addToFavorites`: Adds the provided TV show to the list of the favorite movies of the user.
- `viewFavorites`: Shows the list of the favorite movies of the user.
- `getRecommendations`: Gives the list of the user's recommended movies. Returns this list as an arraylist.
9. Commit your changes, push your commits to your own fork on Github, and create a pull request to merge your changes to the `main` branch of your own fork on Github.
10. Write a report. Your report should contain a UML diagram for each class.

## Notes
- The code provided in this repository gives you a template to work with and build your project. You are allowed to:
- Add new functions and classes to your code wherever you see fit.
- Change and swap the predefined functions as you wish, as long as the program satisfies all the requirements.

- Your report should focus on the structure you choose for each different class, as well as the OOP principles you follow while designing your project. Describe the design of your program, including the classes, objects, methods, and attributes.

- If you implement any bonus features, be sure to include additional details about them in your report.

## Evaluation
- Your code should compile and run without any errors
- Your code should be well-organized, readable, properly commented, and follows clean code principles
- Your code should follow OOP principles and correctly use Java access modifiers
- OOP concepts like polymorphism and encapsulation should be efficiently used in your code.
- You should use Git for version control and include meaningful commit messages (The `main` branch will be used for evaluation)

**Attention: Using ChatGPT or any other AI generative model for any section of the assignment will result in a score of 0 without any warnings.**
1.for the netflixServices i used many different type of searching for movies like their genre ,title or release year .it will show
you a list of the movies that you as the user entered .
2.for the movies class it extends TVShow class and i just added length for each movie
3.in user we have the getRecommendation method that i think it is the only method that worths explaining and based on your ;last favourite
movie it will recommend you similar movies from the same genre if they have higher points than 8.0 .
4.finally i wrote some taste cases and wrote this report .

## Bonus Objectives
1. Perform Input Validation: Ensure the data or information entered by a user or system is correct, complete, and appropriate for the intended use.

2. Extend the available classes to create a more secure login system. Use a hashing algorithm to hash the user's password. Give a brief explanation of the hashing process in your report.

3. Implement any other feature of the Netflix application. For instance, develop the ability for users to like or dislike movies. A user can like or dislike a movie one time. Make sure to include details about these additional features in your report.

4. Use a database in your program; You can choose between NoSQL databases like MongoDB and SQL databases like MySQL, PostgreSQL, etc. Get familiar with java database connectivity (JDBC).

5. Add a simple GUI (Graphical User Interface) to your project. It's recommended to use JavaFX. This GUI should include all of the options offered by the command line menu you implemented earlier. Displaying pictures or icons is optional.

## Submission
- Push your code to your fork on GitHub
- Upload your report to your fork on GitHub
- Create a pull request on the default branch of you own fork of the assignment on GitHub

The deadline for submitting your code is Wednesday, March 15 (24th of Esfand). Any commit made after this date will not affect your score.

Good luck and happy coding!
1.Input Validation
2.i used hash map for passwords and usernames
3.there are more than one way to search and find the movie you want
274 changes: 271 additions & 3 deletions src/main/java/org/example/Main.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,282 @@
package org.example;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
//don't limit yourself to our template ***

static Scanner input = new Scanner(System.in);
static NetflixService netflixService = new NetflixService();

public static void main(String[] args) {

//---------------------------------------------------------movie templates------------------------------------------------------

Movie fiveFeetApart = new Movie("Five Feet Apart", "Romance", 2019, 116, 7.2, new ArrayList<>(Arrays.asList("Haley Lu Richardson", "Cole Sprouse", "Moises Arias")), 116);
Movie interstellar = new Movie("Interstellar", "Science Fiction", 2014, 169, 8.6, new ArrayList<>(Arrays.asList("Matthew McConaughey", "Anne Hathaway", "Jessica Chastain")), 169);
Movie wolfOfWallStreet = new Movie("The Wolf of Wall Street", "Comedy/Drama", 2013, 180, 8.2, new ArrayList<>(Arrays.asList("Leonardo DiCaprio", "Jonah Hill", "Margot Robbie")), 180);

netflixService.addMovie(fiveFeetApart);
netflixService.addMovie(interstellar);
netflixService.addMovie(wolfOfWallStreet);


//---------------------------------------------------------TvShow templates------------------------------------------------------
TVShow friends = new TVShow("Friends", "Sitcom", 1994, 236, 8.9, new ArrayList<>(Arrays.asList("Jennifer Aniston", "Courteney Cox", "Lisa Kudrow")));
TVShow breakingBad = new TVShow("Breaking Bad", "Crime Drama", 2008, 62, 9.4, new ArrayList<>(Arrays.asList("Bryan Cranston", "Aaron Paul", "Anna Gunn")));

netflixService.addTVShow(friends);
netflixService.addTVShow(breakingBad);


//------------------------------------menu stuff----------------------------------
netflixService.createAccount("farid","1234");
netflixMenu();
}

public static void netflixMenu(){
System.out.println("\nNetflix Menu");
System.out.println("1.Create Account");
System.out.println("2.Login");
System.out.println("3.Logout");
System.out.println("4.Search by Title");
System.out.println("5.Search by Genre");
System.out.println("6.Search by Release Year");
System.out.println("7.Search by Release Year in favourites");
System.out.println("8.Search by Title in favourites");
System.out.println("9.Search by Genre in favourites");
System.out.println("10.Get recommendations");
System.out.println("11.Add to favourites");
System.out.println("12.See your favourites");
System.out.println("13.Exit");
int choice = input.nextInt();
input.nextLine();

switch (choice) {
case 1:
createAccount();
netflixMenu();
break;
case 2:
login();
netflixMenu();
break;
case 3:
logout();
netflixMenu();
break;
case 4:
searchByTitle();
netflixMenu();
break;
case 5:
searchByGenre();
netflixMenu();
break;
case 6:
searchByReleaseYear();
netflixMenu();
break;
case 7:
searchByTitleInFavourites();
netflixMenu();
break;
case 8:
searchByGenreInFavourites();
netflixMenu();
break;
case 9:
searchByReleaseYearInFavourites();
netflixMenu();
break;
case 10:
recommendations();
netflixMenu();
break;
case 11:
addToFavourites();
netflixMenu();
break;
case 12:
showFavourites();
netflixMenu();
break;
case 13:
System.out.println("Goodbye!");
return;
default:
System.out.println("Invalid choice! Please try again.");
netflixMenu();
}
}
public static void createAccount() {
System.out.println("Enter a username:");
String username = input.nextLine();
System.out.println("Enter a password:");
String password = input.nextLine();
User user = netflixService.createAccount(username, password);
if (user == null) {
System.out.println("Username is already taken.");
} else {
System.out.println("Account created successfully.");
}
}
public static void login() {
if (netflixService.getCurrentUser() != null) {
System.out.println("You are already logged in as " + netflixService.getCurrentUser().getUserName() + ".");
return;
}

public static void runMenu(){
//TODO:
System.out.println("Enter your username:");
String username = input.nextLine();
System.out.println("Enter your password:");
String password = input.nextLine();

if (netflixService.login(username, password)) {
System.out.println("You logged in successfully.");
//some menu to watch or something
} else {
System.out.println("Wrong password or username!");
login();
}
}
public static void logout() {
if (netflixService.getCurrentUser() == null) {
System.out.println("You are not logged in.");
} else {
System.out.println("Goodbye, " + netflixService.getCurrentUser().getUserName() + "!");
netflixService.logout();
}
}
public static void searchByTitle() {
System.out.println("Enter a title:");
String title = input.nextLine();
ArrayList<TVShow> tvShow = netflixService.searchByTitle(title);
if (tvShow.size() == 0) {
System.out.println("No TV show or movie found with that title.");
} else {
for (TVShow show : tvShow) {
System.out.println("Title: " + show.getTitle());
System.out.println("Genre: " + show.getGenre());
System.out.println("Release Year: " + show.getReleaseYear());
System.out.println("-----------------------");
}
}
}
public static void searchByGenre(){
System.out.println("Enter a genre:");
String genre = input.nextLine();
ArrayList<TVShow> tvShow = netflixService.searchByGenre(genre);
if (tvShow.size() == 0) {
System.out.println("No TV show or movie found with that genre.");
}
else {
for (TVShow show : tvShow) {
System.out.println("Title: " + show.getTitle());
System.out.println("Genre: " + show.getGenre());
System.out.println("Release Year: " + show.getReleaseYear());
System.out.println("-----------------------");
}
}
}
public static void searchByReleaseYear(){
System.out.println("Enter a Year:");
int year = input.nextInt();
ArrayList<TVShow> tvShow = netflixService.searchByReleaseYear(year);
if (tvShow.size() == 0) {
System.out.println("No TV show or movie found in that year.");
}
else {
for (TVShow show : tvShow) {
System.out.println("Title: " + show.getTitle());
System.out.println("Genre: " + show.getGenre());
System.out.println("Release Year: " + show.getReleaseYear());
System.out.println("-----------------------");
}
}
}
public static void searchByTitleInFavourites() {
System.out.println("Enter a title:");
String title = input.nextLine();
ArrayList<TVShow> tvShow = netflixService.getCurrentUser().searchByTitle(title);
if (tvShow.size() == 0) {
System.out.println("No TV show or movie found with that title.");
} else {
for (TVShow show : tvShow) {
System.out.println("Title: " + show.getTitle());
System.out.println("Genre: " + show.getGenre());
System.out.println("Release Year: " + show.getReleaseYear());
System.out.println("-----------------------");
}
}
}
public static void searchByGenreInFavourites(){
System.out.println("Enter a genre:");
String genre = input.nextLine();
ArrayList<TVShow> tvShow = netflixService.getCurrentUser().searchByGenre(genre);
if (tvShow.size() == 0) {
System.out.println("No TV show or movie found with that genre.");
}
else {
for (TVShow show : tvShow) {
System.out.println("Title: " + show.getTitle());
System.out.println("Genre: " + show.getGenre());
System.out.println("Release Year: " + show.getReleaseYear());
System.out.println("-----------------------");
}
}
}
public static void searchByReleaseYearInFavourites(){
System.out.println("Enter a Year:");
int year = input.nextInt();
ArrayList<TVShow> tvShow = netflixService.getCurrentUser().searchByReleaseYear(year);
if (tvShow.size() == 0) {
System.out.println("No TV show or movie found in that year.");
}
else {
for (TVShow show : tvShow) {
System.out.println("Title: " + show.getTitle());
System.out.println("Genre: " + show.getGenre());
System.out.println("Release Year: " + show.getReleaseYear());
System.out.println("-----------------------");
}
}
}
public static void recommendations() {
ArrayList<TVShow> recommendationsList = netflixService.getCurrentUser().getRecommendations(netflixService);
System.out.println("Here are some Movies and Shows you might enjoy:");
for(TVShow show : recommendationsList){
System.out.println("Title: " + show.getTitle());
System.out.println("Genre: " + show.getGenre());
System.out.println("Release Year: " + show.getReleaseYear());
System.out.println("-----------------------");
}
}
public static void addToFavourites(){
System.out.println("Enter a title");
String title = input.nextLine();
if(netflixService.getCurrentUser().getfavouriteShow().contains(netflixService.searchForTitle(title))){
System.out.println("You have already added this movie to your favourites!");
return;
}
if(netflixService.searchForTitle(title) != null) {
netflixService.getCurrentUser().addToFavorites(netflixService.searchForTitle(title));
System.out.println("Movie has been added to the favourites.");
}
else{
System.out.println("Movie not found!");
}
}
public static void showFavourites(){
System.out.println("These are your favourites Show and Movies:");
ArrayList<TVShow> favourites = netflixService.getCurrentUser().getfavouriteShow();
for(TVShow show : favourites){
System.out.println("Title: " + show.getTitle());
System.out.println("Genre: " + show.getGenre());
System.out.println("Release Year: " + show.getReleaseYear());
System.out.println("-----------------------");
}
}
}

Loading