diff --git a/Task2_utkarsh_k/Task2/utkarsh_k/Admin.cpp b/Task2_utkarsh_k/Task2/utkarsh_k/Admin.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Task2_utkarsh_k/Task2/utkarsh_k/Admin.h b/Task2_utkarsh_k/Task2/utkarsh_k/Admin.h new file mode 100644 index 0000000..bb09be4 --- /dev/null +++ b/Task2_utkarsh_k/Task2/utkarsh_k/Admin.h @@ -0,0 +1,60 @@ +#ifndef ADMIN_H +#define ADMIN_H + +#include +#include +#include +#include "Movie.h" +#include "TVShow.h" + +using namespace std; + +class Admin { + string username; + string password; + +public: + Admin(string uname, string pwd) : username(uname), password(pwd) {} + + bool login(string uname, string pwd) { + return (uname == username && pwd == password); + } + + void addMovie(vector& movies, Movie m) { + movies.push_back(m); + cout << "Movie added successfully.\n"; + } + + void addTVShow(vector& shows, TVShow s) { + shows.push_back(s); + cout << "TV Show added successfully.\n"; + } + + void removeMovie(vector& movies, string title) { + for (auto it = movies.begin(); it != movies.end(); ++it) { + if (it->getTitle() == title) { + movies.erase(it); + cout << "Movie removed successfully.\n"; + return; + } + } + cout << "Movie not found.\n"; + } + + void removeTVShow(vector& shows, string title) { + for (auto it = shows.begin(); it != shows.end(); ++it) { + if (it->getTitle() == title) { + shows.erase(it); + cout << "TV Show removed successfully.\n"; + return; + } + } + cout << "TV Show not found.\n"; + } + + void checkUserDues(const User& u) { + cout << u.getUsername() << " owes ₹" << u.getChargesDue() << endl; + } +}; + +#endif diff --git a/Task2_utkarsh_k/Task2/utkarsh_k/Content.h b/Task2_utkarsh_k/Task2/utkarsh_k/Content.h new file mode 100644 index 0000000..d92c7be --- /dev/null +++ b/Task2_utkarsh_k/Task2/utkarsh_k/Content.h @@ -0,0 +1,32 @@ +#ifndef CONTENT_H +#define CONTENT_H + +#include +using namespace std; + +class Content { +protected: + string title; + string genre; + float rating; + bool is_rented; + bool is_purchased; + +public: + Content(string title, string genre, float rating) + : title(title), genre(genre), rating(rating), is_rented(false), is_purchased(false) {} + + virtual void display() = 0; // Pure virtual function + + string getTitle() const { return title; } + string getGenre() const { return genre; } + float getRating() const { return rating; } + + bool getIsRented() const { return is_rented; } + bool getIsPurchased() const { return is_purchased; } + + void setRented(bool rented) { is_rented = rented; } + void setPurchased(bool purchased) { is_purchased = purchased; } +}; + +#endif diff --git a/Task2_utkarsh_k/Task2/utkarsh_k/Dockerfile b/Task2_utkarsh_k/Task2/utkarsh_k/Dockerfile new file mode 100644 index 0000000..5a27929 --- /dev/null +++ b/Task2_utkarsh_k/Task2/utkarsh_k/Dockerfile @@ -0,0 +1,14 @@ +# Use official GCC compiler image +FROM gcc:latest + +# Set working directory +WORKDIR /app + +# Copy all source code into the container +COPY . . + +# Compile all .cpp files into a single executable named netflix +RUN g++ main.cpp Movie.cpp TVShow.cpp Admin.cpp User.cpp -o netflix + +# Command to run the app +CMD ["./netflix"] diff --git a/Task2_utkarsh_k/Task2/utkarsh_k/Movie.cpp b/Task2_utkarsh_k/Task2/utkarsh_k/Movie.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Task2_utkarsh_k/Task2/utkarsh_k/Movie.h b/Task2_utkarsh_k/Task2/utkarsh_k/Movie.h new file mode 100644 index 0000000..7fecc48 --- /dev/null +++ b/Task2_utkarsh_k/Task2/utkarsh_k/Movie.h @@ -0,0 +1,25 @@ +#ifndef MOVIE_H +#define MOVIE_H + +#include "Content.h" +#include + +class Movie : public Content { + int duration; + float rent_cost; + float purchase_cost; + +public: + Movie(string title, string genre, float rating, int duration, float rent_cost, float purchase_cost) + : Content(title, genre, rating), duration(duration), rent_cost(rent_cost), purchase_cost(purchase_cost) {} + + void display() override { + cout << "Movie: " << title << " | Genre: " << genre << " | Rating: " << rating + << " | Duration: " << duration << " min | Rent: ₹" << rent_cost << " | Buy: ₹" << purchase_cost << endl; + } + + float getRentCost() const { return rent_cost; } + float getPurchaseCost() const { return purchase_cost; } +}; + +#endif diff --git a/Task2_utkarsh_k/Task2/utkarsh_k/TVShow.cpp b/Task2_utkarsh_k/Task2/utkarsh_k/TVShow.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Task2_utkarsh_k/Task2/utkarsh_k/TVShow.h b/Task2_utkarsh_k/Task2/utkarsh_k/TVShow.h new file mode 100644 index 0000000..5ed7a89 --- /dev/null +++ b/Task2_utkarsh_k/Task2/utkarsh_k/TVShow.h @@ -0,0 +1,28 @@ +#ifndef TVSHOW_H +#define TVSHOW_H + +#include "Content.h" +#include + +class TVShow : public Content { + int seasons; + int episodes_per_season; + float rent_per_season; + float purchase_per_season; + +public: + TVShow(string title, string genre, float rating, int seasons, int eps, float rent, float purchase) + : Content(title, genre, rating), seasons(seasons), episodes_per_season(eps), + rent_per_season(rent), purchase_per_season(purchase) {} + + void display() override { + cout << "TV Show: " << title << " | Genre: " << genre << " | Rating: " << rating + << " | Seasons: " << seasons << " | Episodes/Season: " << episodes_per_season + << " | Rent/Season: ₹" << rent_per_season << " | Buy/Season: ₹" << purchase_per_season << endl; + } + + float getRentPerSeason() const { return rent_per_season; } + float getPurchasePerSeason() const { return purchase_per_season; } +}; + +#endif diff --git a/Task2_utkarsh_k/Task2/utkarsh_k/data/movie.txt b/Task2_utkarsh_k/Task2/utkarsh_k/data/movie.txt new file mode 100644 index 0000000..e69de29 diff --git a/Task2_utkarsh_k/Task2/utkarsh_k/data/tvshow.txt b/Task2_utkarsh_k/Task2/utkarsh_k/data/tvshow.txt new file mode 100644 index 0000000..e69de29 diff --git a/Task2_utkarsh_k/Task2/utkarsh_k/main.cpp b/Task2_utkarsh_k/Task2/utkarsh_k/main.cpp new file mode 100644 index 0000000..5978f47 --- /dev/null +++ b/Task2_utkarsh_k/Task2/utkarsh_k/main.cpp @@ -0,0 +1,256 @@ +#include +#include +#include +#include +#include "User.h" +#include "Admin.h" +#include "Movie.h" +#include "TVShow.h" + +using namespace std; + +vector users; +vector movies; +vector tvshows; +Admin admin("admin", "admin123"); // Default admin + +void clearInput() { + cin.ignore(numeric_limits::max(), '\n'); +} + +User* userLogin(string uname, string pwd) { + for (auto& u : users) { + if (u.getUsername() == uname && u.checkPassword(pwd)) { + return &u; + } + } + return nullptr; +} + +void signup() { + string uname, pwd; + cout << "Choose username: "; + cin >> uname; + for (auto& u : users) { + if (u.getUsername() == uname) { + cout << "Username already exists.\n"; + return; + } + } + cout << "Choose password: "; + cin >> pwd; + users.emplace_back(uname, pwd); + cout << "User created successfully!\n"; +} + +void browseContent() { + cout << "\n--- Movies ---\n"; + for (auto& m : movies) m.display(); + + cout << "\n--- TV Shows ---\n"; + for (auto& s : tvshows) s.display(); +} + +void userDashboard(User* u) { + int choice; + do { + cout << "\nUser Menu for " << u->getUsername() << "\n"; + cout << "1. Browse Content\n2. Rent Movie\n3. Rent TV Show\n4. Purchase Movie\n5. Purchase TV Show\n6. View Rentals\n7. View Purchases\n8. Return Item\n9. Check Dues\n0. Logout\nChoice: "; + cin >> choice; + + string title; + switch (choice) { + case 1: + browseContent(); + break; + case 2: + cout << "Enter movie title to rent: "; + clearInput(); getline(cin, title); + for (auto& m : movies) { + if (m.getTitle() == title) { + u->rentItem(title, m.getRentCost()); + m.setRented(true); + break; + } + } + break; + case 3: + cout << "Enter TV show title to rent: "; + clearInput(); getline(cin, title); + for (auto& s : tvshows) { + if (s.getTitle() == title) { + u->rentItem(title, s.getRentPerSeason()); + s.setRented(true); + break; + } + } + break; + case 4: + cout << "Enter movie title to purchase: "; + clearInput(); getline(cin, title); + for (auto& m : movies) { + if (m.getTitle() == title) { + u->purchaseItem(title, m.getPurchaseCost()); + m.setPurchased(true); + break; + } + } + break; + case 5: + cout << "Enter TV show title to purchase: "; + clearInput(); getline(cin, title); + for (auto& s : tvshows) { + if (s.getTitle() == title) { + u->purchaseItem(title, s.getPurchasePerSeason()); + s.setPurchased(true); + break; + } + } + break; + case 6: + u->showRentedItems(); break; + case 7: + u->showPurchasedItems(); break; + case 8: + cout << "Enter title to return: "; + clearInput(); getline(cin, title); + u->returnItem(title); + break; + case 9: + cout << "Total due: ₹" << u->getChargesDue() << endl; + break; + case 0: + cout << "Logging out...\n"; break; + default: + cout << "Invalid choice.\n"; + } + } while (choice != 0); +} + +void adminDashboard() { + int choice; + do { + cout << "\nAdmin Menu\n1. Add Movie\n2. Add TV Show\n3. Remove Movie\n4. Remove TV Show\n5. Check User Dues\n0. Logout\nChoice: "; + cin >> choice; + + string title, genre; + float rating; + switch (choice) { + case 1: { + int dur; float rent, buy; + cout << "Title: "; clearInput(); getline(cin, title); + cout << "Genre: "; getline(cin, genre); + cout << "Rating: "; cin >> rating; + cout << "Duration (min): "; cin >> dur; + cout << "Rent ₹: "; cin >> rent; + cout << "Purchase ₹: "; cin >> buy; + Movie m(title, genre, rating, dur, rent, buy); + admin.addMovie(movies, m); + break; + } + case 2: { + int seasons, eps; float rent, buy; + cout << "Title: "; clearInput(); getline(cin, title); + cout << "Genre: "; getline(cin, genre); + cout << "Rating: "; cin >> rating; + cout << "Seasons: "; cin >> seasons; + cout << "Episodes/season: "; cin >> eps; + cout << "Rent/Season ₹: "; cin >> rent; + cout << "Buy/Season ₹: "; cin >> buy; + TVShow s(title, genre, rating, seasons, eps, rent, buy); + admin.addTVShow(tvshows, s); + break; + } + case 3: + cout << "Enter movie title to remove: "; + clearInput(); getline(cin, title); + admin.removeMovie(movies, title); + break; + case 4: + cout << "Enter TV show title to remove: "; + clearInput(); getline(cin, title); + admin.removeTVShow(tvshows, title); + break; + case 5: { + cout << "Enter username to check dues: "; + clearInput(); getline(cin, title); + for (auto& u : users) { + if (u.getUsername() == title) { + admin.checkUserDues(u); + break; + } + } + break; + } + case 0: + cout << "Admin logout...\n"; break; + default: + cout << "Invalid choice.\n"; + } + + } while (choice != 0); +} + +void preloadContent() { + movies.push_back(Movie("Inception", "Sci-Fi", 8.8, 148, 50, 300)); + movies.push_back(Movie("Interstellar", "Sci-Fi", 8.6, 169, 55, 320)); + movies.push_back(Movie("The Dark Knight", "Action", 9.0, 152, 40, 280)); + movies.push_back(Movie("Fight Club", "Drama", 8.8, 139, 45, 250)); + movies.push_back(Movie("The Matrix", "Action", 8.7, 136, 50, 270)); + movies.push_back(Movie("Parasite", "Thriller", 8.6, 132, 35, 230)); + movies.push_back(Movie("Avengers: Endgame", "Superhero", 8.4, 181, 60, 350)); + movies.push_back(Movie("The Godfather", "Crime", 9.2, 175, 45, 300)); + movies.push_back(Movie("Joker", "Crime", 8.4, 122, 40, 260)); + movies.push_back(Movie("Shawshank Redemption", "Drama", 9.3, 142, 40, 280)); + + tvshows.push_back(TVShow("Breaking Bad", "Crime", 9.5, 5, 13, 100, 500)); + tvshows.push_back(TVShow("Stranger Things", "Sci-Fi", 8.7, 4, 10, 80, 400)); + tvshows.push_back(TVShow("Money Heist", "Thriller", 8.3, 5, 8, 90, 420)); + tvshows.push_back(TVShow("Game of Thrones", "Fantasy", 9.2, 8, 10, 110, 550)); + tvshows.push_back(TVShow("Friends", "Comedy", 8.9, 10, 24, 60, 300)); + tvshows.push_back(TVShow("The Office", "Comedy", 8.9, 9, 22, 50, 250)); + tvshows.push_back(TVShow("The Witcher", "Fantasy", 8.2, 3, 8, 75, 370)); + tvshows.push_back(TVShow("Peaky Blinders", "Crime", 8.8, 6, 6, 85, 400)); + tvshows.push_back(TVShow("Lucifer", "Fantasy", 8.1, 6, 10, 70, 360)); + tvshows.push_back(TVShow("Wednesday", "Horror", 8.2, 1, 8, 65, 300)); +} + + +int main() { + preloadContent(); + int choice; + do { + cout << "\n--- Netflix CLI ---\n1. User Login\n2. Sign Up\n3. Admin Login\n0. Exit\nChoice: "; + cin >> choice; + + string uname, pwd; + switch (choice) { + case 1: + cout << "Username: "; cin >> uname; + cout << "Password: "; cin >> pwd; + if (User* u = userLogin(uname, pwd)) { + userDashboard(u); + } else { + cout << "Invalid credentials!\n"; + } + break; + case 2: + signup(); break; + case 3: + cout << "Admin Username: "; cin >> uname; + cout << "Admin Password: "; cin >> pwd; + if (admin.login(uname, pwd)) { + adminDashboard(); + } else { + cout << "Wrong admin credentials.\n"; + } + break; + case 0: + cout << "Bye!\n"; break; + default: + cout << "Invalid choice.\n"; + } + } while (choice != 0); + + return 0; +} diff --git a/Task2_utkarsh_k/Task2/utkarsh_k/main.h b/Task2_utkarsh_k/Task2/utkarsh_k/main.h new file mode 100644 index 0000000..e69de29 diff --git a/Task2_utkarsh_k/Task2/utkarsh_k/user.cpp b/Task2_utkarsh_k/Task2/utkarsh_k/user.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Task2_utkarsh_k/Task2/utkarsh_k/user.h b/Task2_utkarsh_k/Task2/utkarsh_k/user.h new file mode 100644 index 0000000..b930261 --- /dev/null +++ b/Task2_utkarsh_k/Task2/utkarsh_k/user.h @@ -0,0 +1,60 @@ +#ifndef USER_H +#define USER_H + +#include +#include +#include +using namespace std; + +class User { + string username; + string password; + vector rented_items; + vector purchased_items; + float charges_due; + +public: + User(string uname, string pwd) : username(uname), password(pwd), charges_due(0) {} + + string getUsername() const { return username; } + bool checkPassword(string pwd) const { return pwd == password; } + + void rentItem(string title, float cost) { + rented_items.push_back(title); + charges_due += cost; + } + + void purchaseItem(string title, float cost) { + purchased_items.push_back(title); + charges_due += cost; + } + + void returnItem(string title) { + for (auto it = rented_items.begin(); it != rented_items.end(); ++it) { + if (*it == title) { + rented_items.erase(it); + cout << title << " returned successfully.\n"; + return; + } + } + cout << title << " not found in your rented list.\n"; + } + + void showRentedItems() const { + cout << "Rented Items:\n"; + for (const auto& item : rented_items) { + cout << "- " << item << endl; + } + } + + void showPurchasedItems() const { + cout << "Purchased Items:\n"; + for (const auto& item : purchased_items) { + cout << "- " << item << endl; + } + } + + float getChargesDue() const { return charges_due; } +}; + +#endif