From fc149eeb82cded6b8b1b94d7b8522fa380da01ea Mon Sep 17 00:00:00 2001 From: Ram Daftari Date: Tue, 13 May 2025 02:04:35 +0530 Subject: [PATCH 1/2] Finished Assignment 2 --- Task2/ram_d/Dockerfile | 17 + Task2/ram_d/movies_db.txt | 100 ++++++ Task2/ram_d/netflix.cpp | 624 ++++++++++++++++++++++++++++++++++++ Task2/ram_d/password_db.txt | 1 + Task2/ram_d/tv_show_db.txt | 100 ++++++ Task2/ram_d/users/ramd.txt | 4 + 6 files changed, 846 insertions(+) create mode 100644 Task2/ram_d/Dockerfile create mode 100644 Task2/ram_d/movies_db.txt create mode 100644 Task2/ram_d/netflix.cpp create mode 100644 Task2/ram_d/password_db.txt create mode 100644 Task2/ram_d/tv_show_db.txt create mode 100644 Task2/ram_d/users/ramd.txt diff --git a/Task2/ram_d/Dockerfile b/Task2/ram_d/Dockerfile new file mode 100644 index 0000000..b2157a9 --- /dev/null +++ b/Task2/ram_d/Dockerfile @@ -0,0 +1,17 @@ +# C++ base image C++17 support +FROM gcc:11 +RUN apt-get update && apt-get install -y \ + libssl-dev \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app +COPY paste.txt /app/netflix.cpp +RUN mkdir -p /app/users +RUN touch /app/password_db.txt +RUN touch /app/movies_db.txt +RUN touch /app/tv_show_db.txt + +# Compile +RUN g++ -o netflix_app netflix.cpp -lcrypto -std=c++17 -lstdc++fs +RUN chmod +x netflix_app +CMD ["./netflix_app"] diff --git a/Task2/ram_d/movies_db.txt b/Task2/ram_d/movies_db.txt new file mode 100644 index 0000000..a0eb353 --- /dev/null +++ b/Task2/ram_d/movies_db.txt @@ -0,0 +1,100 @@ +No Country for Old Men|Action|5|0|0|151|98|201 +No Country for Old Men|Romance|7|0|0|94|103|205 +Joker|Drama|10|0|0|172|113|260 +Titanic|Drama|5|0|0|141|99|283 +The Grand Budapest Hotel|Romance|5|0|0|152|151|337 +Birdman|Fantasy|3|0|0|149|50|217 +Dunkirk|Drama|4|0|0|95|61|214 +Shutter Island|Sci-Fi|9|0|0|163|121|262 +The Irishman|Sci-Fi|3|0|0|115|55|225 +The Grand Budapest Hotel|Romance|5|0|0|99|154|296 +Black Panther|Action|10|0|0|95|116|267 +The Godfather|Drama|10|0|0|144|60|218 +The Wolf of Wall Street|Action|4|0|0|101|180|334 +Parasite|Thriller|10|0|0|81|112|248 +Joker|Comedy|1|0|0|121|184|307 +Logan|Action|1|0|0|99|69|199 +La La Land|Horror|2|0|0|145|199|379 +Up|Romance|7|0|0|131|116|281 +Interstellar|Action|4|0|0|122|76|241 +The Prestige|Action|1|0|0|168|130|292 +The Dark Knight|Thriller|4|0|0|142|68|245 +Joker|Comedy|4|0|0|92|133|269 +Mad Max: Fury Road|Action|10|0|0|145|73|222 +Coco|Sci-Fi|6|0|0|164|193|377 +Logan|Fantasy|2|0|0|102|101|271 +Forrest Gump|Drama|5|0|0|85|105|230 +Black Panther|Romance|9|0|0|90|168|296 +The Revenant|Action|8|0|0|170|187|381 +Mad Max: Fury Road|Sci-Fi|10|0|0|90|81|254 +Get Out|Fantasy|9|0|0|123|87|244 +The Grand Budapest Hotel|Drama|4|0|0|172|122|308 +Coco|Documentary|10|0|0|116|175|338 +Birdman|Drama|10|0|0|82|175|357 +1917|Horror|4|0|0|170|162|362 +Whiplash|Action|3|0|0|96|185|340 +Joker|Thriller|5|0|0|103|124|277 +Dunkirk|Comedy|4|0|0|105|174|276 +Birdman|Romance|7|0|0|90|193|302 +Logan|Drama|9|0|0|97|51|155 +Joker|Documentary|2|0|0|87|157|320 +Blade Runner 2049|Thriller|10|0|0|104|52|188 +La La Land|Comedy|10|0|0|107|96|224 +Mad Max: Fury Road|Comedy|5|0|0|85|175|331 +Joker|Documentary|8|0|0|113|159|350 +Shutter Island|Romance|6|0|0|179|62|236 +Blade Runner 2049|Sci-Fi|10|0|0|164|80|215 +Get Out|Romance|1|0|0|97|53|234 +La La Land|Thriller|10|0|0|82|197|365 +The Big Short|Drama|9|0|0|167|171|284 +No Country for Old Men|Thriller|5|0|0|158|61|227 +Logan|Action|7|0|0|117|77|206 +A Beautiful Mind|Drama|6|0|0|124|82|237 +Dunkirk|Sci-Fi|9|0|0|167|112|290 +Joker|Romance|8|0|0|115|139|281 +Gladiator|Documentary|5|0|0|144|76|206 +Pulp Fiction|Sci-Fi|6|0|0|132|57|162 +Whiplash|Fantasy|10|0|0|128|139|270 +Inside Out|Romance|5|0|0|110|191|345 +Gladiator|Fantasy|2|0|0|150|99|250 +The Matrix|Action|3|0|0|154|178|327 +Black Panther|Romance|2|0|0|138|187|330 +Pulp Fiction|Horror|10|0|0|103|53|232 +Fight Club|Romance|1|0|0|92|165|312 +Shutter Island|Thriller|4|0|0|173|134|308 +Avengers: Endgame|Action|6|0|0|130|73|216 +The Irishman|Romance|4|0|0|105|144|322 +Forrest Gump|Horror|2|0|0|113|81|187 +Toy Story|Romance|2|0|0|110|73|251 +Inside Out|Horror|3|0|0|174|66|188 +Forrest Gump|Sci-Fi|7|0|0|161|191|349 +Birdman|Sci-Fi|10|0|0|80|103|274 +Mad Max: Fury Road|Drama|6|0|0|125|164|337 +Up|Comedy|4|0|0|121|113|213 +Birdman|Drama|8|0|0|134|168|343 +Inside Out|Action|1|0|0|145|181|283 +Inception|Romance|1|0|0|162|188|312 +Logan|Drama|10|0|0|111|134|326 +Inception|Comedy|7|0|0|165|164|356 +Moonlight|Action|3|0|0|113|175|338 +The Irishman|Action|10|0|0|104|143|336 +The Big Short|Drama|4|0|0|105|111|304 +Whiplash|Romance|5|0|0|172|53|160 +Moonlight|Fantasy|2|0|0|92|75|210 +Gladiator|Thriller|3|0|0|133|156|352 +Blade Runner 2049|Romance|8|0|0|119|190|379 +The Matrix|Drama|6|0|0|102|120|291 +Logan|Sci-Fi|5|0|0|117|83|244 +Shutter Island|Comedy|5|0|0|133|57|213 +Avengers: Endgame|Comedy|1|0|0|90|173|320 +Forrest Gump|Horror|1|0|0|95|198|366 +Interstellar|Comedy|10|0|0|110|133|281 +Up|Action|8|0|0|93|72|242 +Whiplash|Documentary|7|0|0|180|72|232 +The Matrix|Sci-Fi|5|0|0|159|180|284 +Inside Out|Romance|5|0|0|172|101|235 +Fight Club|Horror|5|0|0|92|128|292 +Dunkirk|Romance|1|0|0|166|118|224 +Interstellar|Comedy|3|0|0|136|115|268 +Moonlight|Documentary|3|0|0|178|152|352 +The Wolf of Wall Street|Fantasy|5|0|0|143|152|317 \ No newline at end of file diff --git a/Task2/ram_d/netflix.cpp b/Task2/ram_d/netflix.cpp new file mode 100644 index 0000000..8821084 --- /dev/null +++ b/Task2/ram_d/netflix.cpp @@ -0,0 +1,624 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +string encrypt_password(const string& input_pass) { +// Initially tried a very simple hashing method but then moved to SHA256 in OpenSSL library for better password encryption on local device storage + unsigned char hash[SHA256_DIGEST_LENGTH]; + SHA256((const unsigned char*)input_pass.c_str(), input_pass.length(), hash); + stringstream ss; + for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) { + ss << hex << setw(2) << setfill('0') << (int)hash[i]; + } + return ss.str(); +} + +string verify_credential(){ + string entered_user, entered_pass; + cout<<"Enter your registered username"<>entered_user; + cout<<"Enter your registered password"<>entered_pass; + ifstream infile("password_db.txt"); + string stored_user, stored_pass; + string hashed_entered_pass = encrypt_password(entered_pass); + while (infile >> stored_user >> stored_pass) { + if (stored_user == entered_user && stored_pass == hashed_entered_pass) { + cout<<"Welcome back, "<> init_user; + + bool user_exists = false; + ifstream infile("password_db.txt"); + string stored_user, stored_pass; + while (infile >> stored_user >> stored_pass) { + if (stored_user == init_user) { + user_exists = true; + break; + } + } + infile.close(); + + if (user_exists) { + cout << "Username already exists. Please try a different one." << endl; + continue; + } + + cout << "Enter your password: "; + cin >> init_pass; + cout << "Confirm your password: "; + cin >> init_pass1; + + if (init_pass != init_pass1) { + cout << "Passwords do not match. Please try again." << endl; + continue; + } + + ofstream outfile("password_db.txt", ios::app); + if (outfile.is_open()) { + string hashed = encrypt_password(init_pass); + outfile << init_user << " " << hashed << endl; + outfile.close(); + string userFilePath = "users/" + init_user + ".txt"; + ofstream userFile(userFilePath); + if (userFile.is_open()) { + userFile << "Rented_Movies:\n"; + userFile << "Purchased_Movies:\n"; + userFile << "Rented_TV_Shows:\n"; + userFile << "Purchased_TV_Shows:\n"; + userFile << "Dues: 0\n"; + userFile.close(); + } + else { + cerr << "Error creating user data file.\n"; +} + cout << "User saved successfully! Please log in now." << endl; + break; + } else { + cerr << "Error: Could not open file." << endl; + break; + } + } +} + +class Content{ +public: + string Name; + string Genre; + int Rating; + bool is_rented; + bool is_purchased; +}; + +class TV_Show : public Content{ +public: + int Seasons; + int Episodes_per_Season; + int Per_Season_Rent_Cost; + int Per_Season_Purchase_Cost; +}; + +class Movie : public Content{ +public: + int Duration; + int Rent_Cost; + int Purchase_Cost; +}; + +class Admin { +public: +// Used ChatGPT to generate a lot of such entries for both the database text files based on the formats in the function + void addMovie() { + Movie m; + cout << "Enter movie name: "; + cin >> ws; + getline(cin, m.Name); + cout << "Enter genre: "; + cin >> m.Genre; + cout << "Enter rating (0-10): "; + cin >> m.Rating; + m.is_rented = false; + m.is_purchased = false; + cout << "Enter duration (in minutes): "; + cin >> m.Duration; + cout << "Enter rent cost: "; + cin >> m.Rent_Cost; + cout << "Enter purchase cost: "; + cin >> m.Purchase_Cost; + + ofstream out("movies_db.txt", ios::app); + out << m.Name << "|" << m.Genre << "|" << m.Rating << "|" << m.is_rented << "|" + << m.is_purchased << "|" << m.Duration << "|" << m.Rent_Cost << "|" + << m.Purchase_Cost << "\n"; + + out.close(); + + cout << "Movie added successfully.\n"; + } + + void deleteMovie(const string& movieName) { + ifstream in("movies_db.txt"); + ofstream temp("temp.txt"); + string line; + bool found = false; + while (getline(in, line)) { + istringstream iss(line); + string name; + getline(iss, name, '|'); // updated delimiter from ' ' to '|' + + if (name != movieName) { + temp << line << endl; + } else { + found = true; + } + } + in.close(); + temp.close(); + remove("movies_db.txt"); + rename("temp.txt", "movies_db.txt"); + if (found) + cout << "Movie deleted successfully.\n"; + else + cout << "Movie not found.\n"; + } + + + void addTVShow() { + TV_Show tv; + cout << "Enter TV show name: "; + cin >> ws; + getline(cin, tv.Name); + cout << "Enter genre: "; + cin >> tv.Genre; + cout << "Enter rating (0-10): "; + cin >> tv.Rating; + tv.is_rented = false; + tv.is_purchased = false; + cout << "Enter number of seasons: "; + cin >> tv.Seasons; + cout << "Enter episodes per season: "; + cin >> tv.Episodes_per_Season; + cout << "Enter rent cost per season: "; + cin >> tv.Per_Season_Rent_Cost; + cout << "Enter purchase cost per season: "; + cin >> tv.Per_Season_Purchase_Cost; + + ofstream out("tv_show_db.txt", ios::app); + out << tv.Name << "|" << tv.Genre << "|" << tv.Rating << "|" << tv.is_rented << "|" + << tv.is_purchased << "|" << tv.Seasons << "|" << tv.Episodes_per_Season << "|" + << tv.Per_Season_Rent_Cost << "|" << tv.Per_Season_Purchase_Cost << "\n"; + + out.close(); + + cout << "TV Show added successfully.\n"; + } + + void deleteTVShow(const string& showName) { + ifstream in("tv_show_db.txt"); + ofstream temp("temp.txt"); + string line; + bool found = false; + + while (getline(in, line)) { + istringstream iss(line); + string name; + iss >> ws; + getline(iss, name, '|'); + if (name != showName) { + temp << line << endl; + } else { + found = true; + } + } + + in.close(); + temp.close(); + remove("tv_show_db.txt"); + rename("temp.txt", "tv_show_db.txt"); + + if (found) + cout << "TV Show deleted successfully.\n"; + else + cout << "TV Show not found.\n"; + } +}; + +class User{ + public: + string current_username; + User(const string& uname){ + current_username = uname; + } + + void start_rent() { + int choice; + string preference; + cout << "Press 0 to rent a Movie and Press 1 to rent a TV Show: "; + cin >> choice; + cin.ignore(); + + cout << "Enter the name of the " << (choice ? "TV Show" : "Movie") << " you want to rent:\n"; + getline(cin, preference); + + string dbFile = choice == 0 ? "movies_db.txt" : "tv_show_db.txt"; + string line; + bool found = false; + + ifstream in(dbFile); + while (getline(in, line)) { + stringstream ss(line); + string title; + getline(ss, title, '|'); + + if (title == preference) { + found = true; + break; + } + } + in.close(); + + if (!found) { + cout << (choice ? "TV Show" : "Movie") << " not found.\n"; + return; + } + + // Calculate dues + int duesAmount = (choice == 0) ? 100 : 50; + string userFilePath = "users/" + current_username + ".txt"; + ifstream userIn(userFilePath); + vector fileLines; + string userLine; + while (getline(userIn, userLine)) { + fileLines.push_back(userLine); + } + userIn.close(); + + ofstream userOut(userFilePath); + bool inDuesSection = false; + for (string& line : fileLines) { + if (line == "Dues:") { + inDuesSection = true; + userOut << line << " " << duesAmount << "\n"; + } else { + userOut << line << "\n"; + } + } + userOut.close(); + + cout << "Successfully rented: " << preference << endl; + } + + void purchase() { + int choice; + string title; + cout << "Press 0 to purchase a Movie and Press 1 to purchase a TV Show: "; + cin >> choice; + cin.ignore(); + cout << "Enter the name of the " << (choice ? "TV Show" : "Movie") << " you want to purchase:\n"; + getline(cin, title); + + string userFilePath = "users/" + current_username + ".txt"; + ifstream inFile(userFilePath); + ofstream tempFile("temp_user.txt"); + + string line; + string section = choice == 0 ? "Rented_Movies:" : "Rented_TV_Shows:"; + string nextSection = choice == 0 ? "Purchased_Movies:" : "Purchased_TV_Shows:"; + bool inCorrectSection = false; + + bool found = false; + + while (getline(inFile, line)) { + if (line == section) { + tempFile << line << "\n"; + inCorrectSection = true; + continue; + } + + if (line == nextSection) { + inCorrectSection = false; + tempFile << line << "\n"; + } + + if (inCorrectSection && line == title) { + found = true; + tempFile << line << "\n"; + } else { + tempFile << line << "\n"; + } + } + + // Calculate dues + if (found) { + int duesAmount = (choice == 0) ? 400 : 200; + inFile.close(); + tempFile.close(); + + ifstream userIn(userFilePath); + ofstream userOut("temp_user.txt"); + vector fileLines; + while (getline(userIn, line)) { + fileLines.push_back(line); + } + + userIn.close(); + bool inDuesSection = false; + for (string& line : fileLines) { + if (line == "Dues:") { + inDuesSection = true; + userOut << line << " " << duesAmount << "\n"; + } else { + userOut << line << "\n"; + } + } + remove(userFilePath.c_str()); + rename("temp_user.txt", userFilePath.c_str()); + + cout << "Successfully purchased \"" << title << "\".\n"; + } else { + cout << "The specified " << (choice ? "TV Show" : "Movie") << " was not found in your rented list.\n"; + } + } + + void end_rent() { + int choice; + string title; + cout << "Press 0 to return a Movie and Press 1 to return a TV Show: "; + cin >> choice; + cin.ignore(); + cout << "Enter the name of the " << (choice ? "TV Show" : "Movie") << " you want to return:\n"; + getline(cin, title); + + string userFilePath = "users/" + current_username + ".txt"; + ifstream inFile(userFilePath); + ofstream tempFile("temp_user.txt"); + + string line; + string section = choice == 0 ? "Rented_Movies:" : "Rented_TV_Shows:"; + string nextSection = choice == 0 ? "Purchased_Movies:" : "Purchased_TV_Shows:"; + + bool inCorrectSection = false; + bool found = false; + + while (getline(inFile, line)) { + if (line == section) { + tempFile << line << "\n"; + inCorrectSection = true; + continue; + } + + if (line == nextSection) { + inCorrectSection = false; + tempFile << line << "\n"; + continue; + } + + if (inCorrectSection && line == title) { + found = true; + continue; + } + + tempFile << line << "\n"; + } + + inFile.close(); + tempFile.close(); + + remove(userFilePath.c_str()); + rename("temp_user.txt", userFilePath.c_str()); + + if (found) + cout << "Successfully returned \"" << title << "\".\n"; + else + cout << "The specified " << (choice ? "TV Show" : "Movie") << " was not found in your rented list.\n"; + } + + void view_rent() { + string userFilePath = "users/" + current_username + ".txt"; + ifstream inFile(userFilePath); + string line; + bool inRentedMovies = false; + bool inRentedTVShows = false; + + cout << "Movies you have rented:\n"; + while (getline(inFile, line)) { + if (line == "Rented_Movies:") { + inRentedMovies = true; + continue; + } + if (line == "Rented_TV_Shows:") { + inRentedMovies = false; + inRentedTVShows = true; + continue; + } + + if (inRentedMovies) { + cout << line << "\n"; + } else if (inRentedTVShows) { + cout << line << "\n"; + } + } + + if (!inRentedMovies && !inRentedTVShows) { + cout << "You haven't rented any movies or TV shows yet.\n"; + } + + inFile.close(); + } + + void view_purchase() { + string userFilePath = "users/" + current_username + ".txt"; + ifstream inFile(userFilePath); + string line; + bool inPurchasedMovies = false; + bool inPurchasedTVShows = false; + + cout << "Movies you have purchased:\n"; + while (getline(inFile, line)) { + if (line == "Purchased_Movies:") { + inPurchasedMovies = true; + continue; + } + if (line == "Purchased_TV_Shows:") { + inPurchasedMovies = false; + inPurchasedTVShows = true; + continue; + } + + if (inPurchasedMovies) { + cout << line << "\n"; + } else if (inPurchasedTVShows) { + cout << line << "\n"; + } + } + + if (!inPurchasedMovies && !inPurchasedTVShows) { + cout << "You haven't purchased any movies or TV shows yet.\n"; + } + + inFile.close(); + } + + void check_dues() { + string userFilePath = "users/" + current_username + ".txt"; + ifstream inFile(userFilePath); + string line; + bool inDuesSection = false; + + // Look for dues section and print the dues for the user + while (getline(inFile, line)) { + if (line.find("Dues:") != string::npos) { + // Output dues by extracting the part after "Dues: " + cout << "Dues for " << current_username << ": " << line.substr(5) << endl; + inDuesSection = true; + break; + } + } + + if (!inDuesSection) { + cout << "No dues found for " << current_username << endl; + } + + inFile.close(); + } + +}; + +int main() { + int control; + string logged_user; + cout << "Welcome to Netflix. Press 0 if you are a user and Press 1 if you are an admin" << endl; + cin >> control; + + if (control) { + cout << "Welcome admin. Please log-in."; + if (verify_credential() != "") { // Only proceed if valid admin + Admin adminUser; + bool running = true; + while (running) { + cout << "\nAdmin Menu:" << endl; + cout << "1. Add Movie" << endl; + cout << "2. Delete Movie" << endl; + cout << "3. Add TV Show" << endl; + cout << "4. Delete TV Show" << endl; + cout << "5. Exit" << endl; + cin >> control; + string contentName; + + switch(control) { + case 1: + adminUser.addMovie(); + break; + case 2: + cout << "Enter movie name to delete: "; + cin.ignore(); + getline(cin, contentName); + adminUser.deleteMovie(contentName); + break; + case 3: + adminUser.addTVShow(); + break; + case 4: + cout << "Enter TV show name to delete: "; + cin.ignore(); + getline(cin, contentName); + adminUser.deleteTVShow(contentName); + break; + case 5: + running = false; + break; + } + } + } + } else { + cout << "Welcome user. Press 0 to sign-up and Press 1 to log-in" << endl; + cin >> control; + + if (control) { + // User logs in + logged_user = verify_credential(); + } else { + // New user sign-up + make_credential(); + logged_user = verify_credential(); + } + + // Once logged in, create or get a reference to the User object + User currentUser(logged_user); + + // User selects actions + bool running = true; + while (running) { + cout << "\nWhat would you like to do?" << endl; + cout << "1. Rent a movie or TV show" << endl; + cout << "2. Purchase a movie or TV show" << endl; + cout << "3. Return rented content" << endl; + cout << "4. View rented content" << endl; + cout << "5. View purchased content" << endl; + cout << "6. Check total charges due" << endl; + cout << "7. Exit" << endl; + cin >> control; + switch(control){ + case 1: + currentUser.start_rent(); + break; + case 2: + currentUser.purchase(); + break; + case 3: + currentUser.end_rent(); + break; + case 4: + currentUser.view_rent(); + break; + case 5: + currentUser.view_purchase(); + break; + case 6: + currentUser.check_dues(); + break; + case 7: + return 0; + } + } + } +} diff --git a/Task2/ram_d/password_db.txt b/Task2/ram_d/password_db.txt new file mode 100644 index 0000000..c0038b6 --- /dev/null +++ b/Task2/ram_d/password_db.txt @@ -0,0 +1 @@ +ramd 3bc74a9189734d9836988a251d73a729bf55d448c06fed1291d59ddf323f159c diff --git a/Task2/ram_d/tv_show_db.txt b/Task2/ram_d/tv_show_db.txt new file mode 100644 index 0000000..67070b0 --- /dev/null +++ b/Task2/ram_d/tv_show_db.txt @@ -0,0 +1,100 @@ +Arrested Development|Fantasy|1|0|0|8|16|189|486 +Homeland|Sci-Fi|5|0|0|1|20|293|460 +Dark|Drama|2|0|0|7|6|141|317 +Game of Thrones|Fantasy|7|0|0|6|23|148|342 +Arrested Development|Romance|9|0|0|7|11|266|384 +Money Heist|Romance|10|0|0|3|22|259|447 +The Queen's Gambit|Sci-Fi|7|0|0|10|9|217|515 +Rick and Morty|Romance|6|0|0|7|24|263|404 +Better Call Saul|Horror|8|0|0|4|19|167|454 +The Office|Sci-Fi|3|0|0|10|10|129|397 +Mindhunter|Romance|6|0|0|9|24|176|286 +Stranger Things|Romance|3|0|0|7|21|295|435 +The Handmaid's Tale|Thriller|1|0|0|8|10|299|566 +Dark|Thriller|5|0|0|1|11|151|383 +The Handmaid's Tale|Romance|8|0|0|10|16|193|451 +Stranger Things|Thriller|6|0|0|8|19|256|360 +Loki|Sci-Fi|3|0|0|4|7|215|361 +Homeland|Comedy|8|0|0|4|23|166|416 +Fargo|Horror|7|0|0|5|8|147|442 +Chernobyl|Thriller|2|0|0|3|7|281|511 +Breaking Bad|Documentary|7|0|0|4|8|171|401 +Peaky Blinders|Drama|1|0|0|1|16|254|374 +Stranger Things|Fantasy|9|0|0|9|23|215|374 +The Umbrella Academy|Action|5|0|0|8|13|193|372 +WandaVision|Sci-Fi|5|0|0|10|19|225|343 +This Is Us|Fantasy|4|0|0|10|13|184|306 +Dark|Comedy|10|0|0|4|10|257|424 +Breaking Bad|Fantasy|9|0|0|9|11|180|333 +WandaVision|Fantasy|4|0|0|3|8|188|349 +The 100|Sci-Fi|7|0|0|5|19|180|280 +Stranger Things|Fantasy|9|0|0|8|12|209|398 +Arrested Development|Sci-Fi|3|0|0|7|19|288|499 +Friends|Sci-Fi|7|0|0|4|10|266|493 +Narcos|Horror|5|0|0|2|13|136|406 +WandaVision|Thriller|1|0|0|1|21|243|519 +Friends|Action|6|0|0|4|11|153|409 +Loki|Drama|1|0|0|1|24|247|422 +Chernobyl|Thriller|9|0|0|8|17|207|458 +Sherlock|Drama|8|0|0|5|9|128|345 +Rick and Morty|Romance|1|0|0|8|6|225|458 +The Mandalorian|Thriller|8|0|0|10|7|158|370 +Lost|Romance|4|0|0|3|7|219|386 +Mindhunter|Romance|8|0|0|7|14|224|358 +BoJack Horseman|Comedy|7|0|0|4|15|246|434 +Better Call Saul|Sci-Fi|7|0|0|6|24|109|320 +Black Mirror|Thriller|6|0|0|7|15|292|547 +Stranger Things|Horror|4|0|0|8|14|204|321 +Chernobyl|Horror|5|0|0|4|8|281|558 +Better Call Saul|Action|5|0|0|1|15|118|396 +Stranger Things|Sci-Fi|2|0|0|10|20|267|537 +WandaVision|Sci-Fi|6|0|0|8|22|135|402 +Mindhunter|Comedy|1|0|0|7|11|172|398 +The Umbrella Academy|Horror|1|0|0|3|16|257|452 +Fargo|Sci-Fi|4|0|0|8|11|196|351 +The 100|Sci-Fi|9|0|0|8|8|186|301 +WandaVision|Documentary|8|0|0|5|19|261|513 +Lost|Fantasy|1|0|0|9|6|199|491 +BoJack Horseman|Thriller|7|0|0|2|12|265|411 +The Office|Action|9|0|0|10|10|170|369 +Homeland|Sci-Fi|2|0|0|8|12|244|504 +Lost|Documentary|4|0|0|2|13|288|529 +Homeland|Documentary|10|0|0|8|6|249|399 +Money Heist|Fantasy|5|0|0|10|7|165|423 +The Witcher|Thriller|2|0|0|7|14|281|434 +The Office|Fantasy|9|0|0|5|6|103|239 +Brooklyn Nine-Nine|Sci-Fi|8|0|0|6|16|138|287 +This Is Us|Sci-Fi|1|0|0|7|12|277|387 +Loki|Comedy|6|0|0|6|8|161|302 +The Boys|Action|4|0|0|5|16|131|270 +The Queen's Gambit|Thriller|1|0|0|9|6|138|324 +Better Call Saul|Action|3|0|0|10|20|282|455 +Arrested Development|Horror|3|0|0|9|7|203|358 +The Office|Drama|2|0|0|4|10|176|449 +Dark|Action|4|0|0|1|19|287|569 +Peaky Blinders|Thriller|1|0|0|8|19|237|506 +The Marvelous Mrs. Maisel|Action|7|0|0|5|19|164|331 +House of Cards|Action|4|0|0|10|10|271|530 +The Crown|Documentary|3|0|0|3|22|209|313 +House of Cards|Romance|5|0|0|1|9|266|434 +Better Call Saul|Action|2|0|0|2|22|253|501 +Stranger Things|Comedy|6|0|0|3|15|248|455 +Breaking Bad|Drama|5|0|0|2|19|275|399 +WandaVision|Action|5|0|0|10|12|144|350 +Narcos|Sci-Fi|1|0|0|9|20|261|421 +Narcos|Comedy|8|0|0|7|6|109|321 +Brooklyn Nine-Nine|Romance|10|0|0|10|6|217|428 +The Handmaid's Tale|Thriller|3|0|0|6|24|273|483 +Fargo|Sci-Fi|1|0|0|10|15|126|358 +Brooklyn Nine-Nine|Action|6|0|0|1|18|292|554 +Mindhunter|Action|5|0|0|3|12|123|333 +Dexter|Drama|7|0|0|3|18|189|353 +Money Heist|Thriller|1|0|0|4|23|219|447 +Westworld|Thriller|3|0|0|4|6|266|402 +Fargo|Fantasy|4|0|0|4|23|121|224 +The Umbrella Academy|Fantasy|10|0|0|2|13|271|537 +Ozark|Sci-Fi|2|0|0|1|24|119|386 +BoJack Horseman|Fantasy|3|0|0|3|21|283|558 +Homeland|Action|5|0|0|8|19|204|427 +The Marvelous Mrs. Maisel|Action|10|0|0|5|11|259|377 +House of Cards|Documentary|7|0|0|1|20|259|366 \ No newline at end of file diff --git a/Task2/ram_d/users/ramd.txt b/Task2/ram_d/users/ramd.txt new file mode 100644 index 0000000..23ee80e --- /dev/null +++ b/Task2/ram_d/users/ramd.txt @@ -0,0 +1,4 @@ +Rented_Movies: +Purchased_Movies: +Rented_TV_Shows: +Purchased_TV_Shows: From 6b96bf21b8d53b128cebd44461e3faeb033db44c Mon Sep 17 00:00:00 2001 From: Ram Daftari Date: Tue, 13 May 2025 02:11:19 +0530 Subject: [PATCH 2/2] Delete Task2/ram_d directory --- Task2/ram_d/Dockerfile | 17 - Task2/ram_d/movies_db.txt | 100 ------ Task2/ram_d/netflix.cpp | 624 ------------------------------------ Task2/ram_d/password_db.txt | 1 - Task2/ram_d/tv_show_db.txt | 100 ------ Task2/ram_d/users/ramd.txt | 4 - 6 files changed, 846 deletions(-) delete mode 100644 Task2/ram_d/Dockerfile delete mode 100644 Task2/ram_d/movies_db.txt delete mode 100644 Task2/ram_d/netflix.cpp delete mode 100644 Task2/ram_d/password_db.txt delete mode 100644 Task2/ram_d/tv_show_db.txt delete mode 100644 Task2/ram_d/users/ramd.txt diff --git a/Task2/ram_d/Dockerfile b/Task2/ram_d/Dockerfile deleted file mode 100644 index b2157a9..0000000 --- a/Task2/ram_d/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -# C++ base image C++17 support -FROM gcc:11 -RUN apt-get update && apt-get install -y \ - libssl-dev \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /app -COPY paste.txt /app/netflix.cpp -RUN mkdir -p /app/users -RUN touch /app/password_db.txt -RUN touch /app/movies_db.txt -RUN touch /app/tv_show_db.txt - -# Compile -RUN g++ -o netflix_app netflix.cpp -lcrypto -std=c++17 -lstdc++fs -RUN chmod +x netflix_app -CMD ["./netflix_app"] diff --git a/Task2/ram_d/movies_db.txt b/Task2/ram_d/movies_db.txt deleted file mode 100644 index a0eb353..0000000 --- a/Task2/ram_d/movies_db.txt +++ /dev/null @@ -1,100 +0,0 @@ -No Country for Old Men|Action|5|0|0|151|98|201 -No Country for Old Men|Romance|7|0|0|94|103|205 -Joker|Drama|10|0|0|172|113|260 -Titanic|Drama|5|0|0|141|99|283 -The Grand Budapest Hotel|Romance|5|0|0|152|151|337 -Birdman|Fantasy|3|0|0|149|50|217 -Dunkirk|Drama|4|0|0|95|61|214 -Shutter Island|Sci-Fi|9|0|0|163|121|262 -The Irishman|Sci-Fi|3|0|0|115|55|225 -The Grand Budapest Hotel|Romance|5|0|0|99|154|296 -Black Panther|Action|10|0|0|95|116|267 -The Godfather|Drama|10|0|0|144|60|218 -The Wolf of Wall Street|Action|4|0|0|101|180|334 -Parasite|Thriller|10|0|0|81|112|248 -Joker|Comedy|1|0|0|121|184|307 -Logan|Action|1|0|0|99|69|199 -La La Land|Horror|2|0|0|145|199|379 -Up|Romance|7|0|0|131|116|281 -Interstellar|Action|4|0|0|122|76|241 -The Prestige|Action|1|0|0|168|130|292 -The Dark Knight|Thriller|4|0|0|142|68|245 -Joker|Comedy|4|0|0|92|133|269 -Mad Max: Fury Road|Action|10|0|0|145|73|222 -Coco|Sci-Fi|6|0|0|164|193|377 -Logan|Fantasy|2|0|0|102|101|271 -Forrest Gump|Drama|5|0|0|85|105|230 -Black Panther|Romance|9|0|0|90|168|296 -The Revenant|Action|8|0|0|170|187|381 -Mad Max: Fury Road|Sci-Fi|10|0|0|90|81|254 -Get Out|Fantasy|9|0|0|123|87|244 -The Grand Budapest Hotel|Drama|4|0|0|172|122|308 -Coco|Documentary|10|0|0|116|175|338 -Birdman|Drama|10|0|0|82|175|357 -1917|Horror|4|0|0|170|162|362 -Whiplash|Action|3|0|0|96|185|340 -Joker|Thriller|5|0|0|103|124|277 -Dunkirk|Comedy|4|0|0|105|174|276 -Birdman|Romance|7|0|0|90|193|302 -Logan|Drama|9|0|0|97|51|155 -Joker|Documentary|2|0|0|87|157|320 -Blade Runner 2049|Thriller|10|0|0|104|52|188 -La La Land|Comedy|10|0|0|107|96|224 -Mad Max: Fury Road|Comedy|5|0|0|85|175|331 -Joker|Documentary|8|0|0|113|159|350 -Shutter Island|Romance|6|0|0|179|62|236 -Blade Runner 2049|Sci-Fi|10|0|0|164|80|215 -Get Out|Romance|1|0|0|97|53|234 -La La Land|Thriller|10|0|0|82|197|365 -The Big Short|Drama|9|0|0|167|171|284 -No Country for Old Men|Thriller|5|0|0|158|61|227 -Logan|Action|7|0|0|117|77|206 -A Beautiful Mind|Drama|6|0|0|124|82|237 -Dunkirk|Sci-Fi|9|0|0|167|112|290 -Joker|Romance|8|0|0|115|139|281 -Gladiator|Documentary|5|0|0|144|76|206 -Pulp Fiction|Sci-Fi|6|0|0|132|57|162 -Whiplash|Fantasy|10|0|0|128|139|270 -Inside Out|Romance|5|0|0|110|191|345 -Gladiator|Fantasy|2|0|0|150|99|250 -The Matrix|Action|3|0|0|154|178|327 -Black Panther|Romance|2|0|0|138|187|330 -Pulp Fiction|Horror|10|0|0|103|53|232 -Fight Club|Romance|1|0|0|92|165|312 -Shutter Island|Thriller|4|0|0|173|134|308 -Avengers: Endgame|Action|6|0|0|130|73|216 -The Irishman|Romance|4|0|0|105|144|322 -Forrest Gump|Horror|2|0|0|113|81|187 -Toy Story|Romance|2|0|0|110|73|251 -Inside Out|Horror|3|0|0|174|66|188 -Forrest Gump|Sci-Fi|7|0|0|161|191|349 -Birdman|Sci-Fi|10|0|0|80|103|274 -Mad Max: Fury Road|Drama|6|0|0|125|164|337 -Up|Comedy|4|0|0|121|113|213 -Birdman|Drama|8|0|0|134|168|343 -Inside Out|Action|1|0|0|145|181|283 -Inception|Romance|1|0|0|162|188|312 -Logan|Drama|10|0|0|111|134|326 -Inception|Comedy|7|0|0|165|164|356 -Moonlight|Action|3|0|0|113|175|338 -The Irishman|Action|10|0|0|104|143|336 -The Big Short|Drama|4|0|0|105|111|304 -Whiplash|Romance|5|0|0|172|53|160 -Moonlight|Fantasy|2|0|0|92|75|210 -Gladiator|Thriller|3|0|0|133|156|352 -Blade Runner 2049|Romance|8|0|0|119|190|379 -The Matrix|Drama|6|0|0|102|120|291 -Logan|Sci-Fi|5|0|0|117|83|244 -Shutter Island|Comedy|5|0|0|133|57|213 -Avengers: Endgame|Comedy|1|0|0|90|173|320 -Forrest Gump|Horror|1|0|0|95|198|366 -Interstellar|Comedy|10|0|0|110|133|281 -Up|Action|8|0|0|93|72|242 -Whiplash|Documentary|7|0|0|180|72|232 -The Matrix|Sci-Fi|5|0|0|159|180|284 -Inside Out|Romance|5|0|0|172|101|235 -Fight Club|Horror|5|0|0|92|128|292 -Dunkirk|Romance|1|0|0|166|118|224 -Interstellar|Comedy|3|0|0|136|115|268 -Moonlight|Documentary|3|0|0|178|152|352 -The Wolf of Wall Street|Fantasy|5|0|0|143|152|317 \ No newline at end of file diff --git a/Task2/ram_d/netflix.cpp b/Task2/ram_d/netflix.cpp deleted file mode 100644 index 8821084..0000000 --- a/Task2/ram_d/netflix.cpp +++ /dev/null @@ -1,624 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -string encrypt_password(const string& input_pass) { -// Initially tried a very simple hashing method but then moved to SHA256 in OpenSSL library for better password encryption on local device storage - unsigned char hash[SHA256_DIGEST_LENGTH]; - SHA256((const unsigned char*)input_pass.c_str(), input_pass.length(), hash); - stringstream ss; - for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) { - ss << hex << setw(2) << setfill('0') << (int)hash[i]; - } - return ss.str(); -} - -string verify_credential(){ - string entered_user, entered_pass; - cout<<"Enter your registered username"<>entered_user; - cout<<"Enter your registered password"<>entered_pass; - ifstream infile("password_db.txt"); - string stored_user, stored_pass; - string hashed_entered_pass = encrypt_password(entered_pass); - while (infile >> stored_user >> stored_pass) { - if (stored_user == entered_user && stored_pass == hashed_entered_pass) { - cout<<"Welcome back, "<> init_user; - - bool user_exists = false; - ifstream infile("password_db.txt"); - string stored_user, stored_pass; - while (infile >> stored_user >> stored_pass) { - if (stored_user == init_user) { - user_exists = true; - break; - } - } - infile.close(); - - if (user_exists) { - cout << "Username already exists. Please try a different one." << endl; - continue; - } - - cout << "Enter your password: "; - cin >> init_pass; - cout << "Confirm your password: "; - cin >> init_pass1; - - if (init_pass != init_pass1) { - cout << "Passwords do not match. Please try again." << endl; - continue; - } - - ofstream outfile("password_db.txt", ios::app); - if (outfile.is_open()) { - string hashed = encrypt_password(init_pass); - outfile << init_user << " " << hashed << endl; - outfile.close(); - string userFilePath = "users/" + init_user + ".txt"; - ofstream userFile(userFilePath); - if (userFile.is_open()) { - userFile << "Rented_Movies:\n"; - userFile << "Purchased_Movies:\n"; - userFile << "Rented_TV_Shows:\n"; - userFile << "Purchased_TV_Shows:\n"; - userFile << "Dues: 0\n"; - userFile.close(); - } - else { - cerr << "Error creating user data file.\n"; -} - cout << "User saved successfully! Please log in now." << endl; - break; - } else { - cerr << "Error: Could not open file." << endl; - break; - } - } -} - -class Content{ -public: - string Name; - string Genre; - int Rating; - bool is_rented; - bool is_purchased; -}; - -class TV_Show : public Content{ -public: - int Seasons; - int Episodes_per_Season; - int Per_Season_Rent_Cost; - int Per_Season_Purchase_Cost; -}; - -class Movie : public Content{ -public: - int Duration; - int Rent_Cost; - int Purchase_Cost; -}; - -class Admin { -public: -// Used ChatGPT to generate a lot of such entries for both the database text files based on the formats in the function - void addMovie() { - Movie m; - cout << "Enter movie name: "; - cin >> ws; - getline(cin, m.Name); - cout << "Enter genre: "; - cin >> m.Genre; - cout << "Enter rating (0-10): "; - cin >> m.Rating; - m.is_rented = false; - m.is_purchased = false; - cout << "Enter duration (in minutes): "; - cin >> m.Duration; - cout << "Enter rent cost: "; - cin >> m.Rent_Cost; - cout << "Enter purchase cost: "; - cin >> m.Purchase_Cost; - - ofstream out("movies_db.txt", ios::app); - out << m.Name << "|" << m.Genre << "|" << m.Rating << "|" << m.is_rented << "|" - << m.is_purchased << "|" << m.Duration << "|" << m.Rent_Cost << "|" - << m.Purchase_Cost << "\n"; - - out.close(); - - cout << "Movie added successfully.\n"; - } - - void deleteMovie(const string& movieName) { - ifstream in("movies_db.txt"); - ofstream temp("temp.txt"); - string line; - bool found = false; - while (getline(in, line)) { - istringstream iss(line); - string name; - getline(iss, name, '|'); // updated delimiter from ' ' to '|' - - if (name != movieName) { - temp << line << endl; - } else { - found = true; - } - } - in.close(); - temp.close(); - remove("movies_db.txt"); - rename("temp.txt", "movies_db.txt"); - if (found) - cout << "Movie deleted successfully.\n"; - else - cout << "Movie not found.\n"; - } - - - void addTVShow() { - TV_Show tv; - cout << "Enter TV show name: "; - cin >> ws; - getline(cin, tv.Name); - cout << "Enter genre: "; - cin >> tv.Genre; - cout << "Enter rating (0-10): "; - cin >> tv.Rating; - tv.is_rented = false; - tv.is_purchased = false; - cout << "Enter number of seasons: "; - cin >> tv.Seasons; - cout << "Enter episodes per season: "; - cin >> tv.Episodes_per_Season; - cout << "Enter rent cost per season: "; - cin >> tv.Per_Season_Rent_Cost; - cout << "Enter purchase cost per season: "; - cin >> tv.Per_Season_Purchase_Cost; - - ofstream out("tv_show_db.txt", ios::app); - out << tv.Name << "|" << tv.Genre << "|" << tv.Rating << "|" << tv.is_rented << "|" - << tv.is_purchased << "|" << tv.Seasons << "|" << tv.Episodes_per_Season << "|" - << tv.Per_Season_Rent_Cost << "|" << tv.Per_Season_Purchase_Cost << "\n"; - - out.close(); - - cout << "TV Show added successfully.\n"; - } - - void deleteTVShow(const string& showName) { - ifstream in("tv_show_db.txt"); - ofstream temp("temp.txt"); - string line; - bool found = false; - - while (getline(in, line)) { - istringstream iss(line); - string name; - iss >> ws; - getline(iss, name, '|'); - if (name != showName) { - temp << line << endl; - } else { - found = true; - } - } - - in.close(); - temp.close(); - remove("tv_show_db.txt"); - rename("temp.txt", "tv_show_db.txt"); - - if (found) - cout << "TV Show deleted successfully.\n"; - else - cout << "TV Show not found.\n"; - } -}; - -class User{ - public: - string current_username; - User(const string& uname){ - current_username = uname; - } - - void start_rent() { - int choice; - string preference; - cout << "Press 0 to rent a Movie and Press 1 to rent a TV Show: "; - cin >> choice; - cin.ignore(); - - cout << "Enter the name of the " << (choice ? "TV Show" : "Movie") << " you want to rent:\n"; - getline(cin, preference); - - string dbFile = choice == 0 ? "movies_db.txt" : "tv_show_db.txt"; - string line; - bool found = false; - - ifstream in(dbFile); - while (getline(in, line)) { - stringstream ss(line); - string title; - getline(ss, title, '|'); - - if (title == preference) { - found = true; - break; - } - } - in.close(); - - if (!found) { - cout << (choice ? "TV Show" : "Movie") << " not found.\n"; - return; - } - - // Calculate dues - int duesAmount = (choice == 0) ? 100 : 50; - string userFilePath = "users/" + current_username + ".txt"; - ifstream userIn(userFilePath); - vector fileLines; - string userLine; - while (getline(userIn, userLine)) { - fileLines.push_back(userLine); - } - userIn.close(); - - ofstream userOut(userFilePath); - bool inDuesSection = false; - for (string& line : fileLines) { - if (line == "Dues:") { - inDuesSection = true; - userOut << line << " " << duesAmount << "\n"; - } else { - userOut << line << "\n"; - } - } - userOut.close(); - - cout << "Successfully rented: " << preference << endl; - } - - void purchase() { - int choice; - string title; - cout << "Press 0 to purchase a Movie and Press 1 to purchase a TV Show: "; - cin >> choice; - cin.ignore(); - cout << "Enter the name of the " << (choice ? "TV Show" : "Movie") << " you want to purchase:\n"; - getline(cin, title); - - string userFilePath = "users/" + current_username + ".txt"; - ifstream inFile(userFilePath); - ofstream tempFile("temp_user.txt"); - - string line; - string section = choice == 0 ? "Rented_Movies:" : "Rented_TV_Shows:"; - string nextSection = choice == 0 ? "Purchased_Movies:" : "Purchased_TV_Shows:"; - bool inCorrectSection = false; - - bool found = false; - - while (getline(inFile, line)) { - if (line == section) { - tempFile << line << "\n"; - inCorrectSection = true; - continue; - } - - if (line == nextSection) { - inCorrectSection = false; - tempFile << line << "\n"; - } - - if (inCorrectSection && line == title) { - found = true; - tempFile << line << "\n"; - } else { - tempFile << line << "\n"; - } - } - - // Calculate dues - if (found) { - int duesAmount = (choice == 0) ? 400 : 200; - inFile.close(); - tempFile.close(); - - ifstream userIn(userFilePath); - ofstream userOut("temp_user.txt"); - vector fileLines; - while (getline(userIn, line)) { - fileLines.push_back(line); - } - - userIn.close(); - bool inDuesSection = false; - for (string& line : fileLines) { - if (line == "Dues:") { - inDuesSection = true; - userOut << line << " " << duesAmount << "\n"; - } else { - userOut << line << "\n"; - } - } - remove(userFilePath.c_str()); - rename("temp_user.txt", userFilePath.c_str()); - - cout << "Successfully purchased \"" << title << "\".\n"; - } else { - cout << "The specified " << (choice ? "TV Show" : "Movie") << " was not found in your rented list.\n"; - } - } - - void end_rent() { - int choice; - string title; - cout << "Press 0 to return a Movie and Press 1 to return a TV Show: "; - cin >> choice; - cin.ignore(); - cout << "Enter the name of the " << (choice ? "TV Show" : "Movie") << " you want to return:\n"; - getline(cin, title); - - string userFilePath = "users/" + current_username + ".txt"; - ifstream inFile(userFilePath); - ofstream tempFile("temp_user.txt"); - - string line; - string section = choice == 0 ? "Rented_Movies:" : "Rented_TV_Shows:"; - string nextSection = choice == 0 ? "Purchased_Movies:" : "Purchased_TV_Shows:"; - - bool inCorrectSection = false; - bool found = false; - - while (getline(inFile, line)) { - if (line == section) { - tempFile << line << "\n"; - inCorrectSection = true; - continue; - } - - if (line == nextSection) { - inCorrectSection = false; - tempFile << line << "\n"; - continue; - } - - if (inCorrectSection && line == title) { - found = true; - continue; - } - - tempFile << line << "\n"; - } - - inFile.close(); - tempFile.close(); - - remove(userFilePath.c_str()); - rename("temp_user.txt", userFilePath.c_str()); - - if (found) - cout << "Successfully returned \"" << title << "\".\n"; - else - cout << "The specified " << (choice ? "TV Show" : "Movie") << " was not found in your rented list.\n"; - } - - void view_rent() { - string userFilePath = "users/" + current_username + ".txt"; - ifstream inFile(userFilePath); - string line; - bool inRentedMovies = false; - bool inRentedTVShows = false; - - cout << "Movies you have rented:\n"; - while (getline(inFile, line)) { - if (line == "Rented_Movies:") { - inRentedMovies = true; - continue; - } - if (line == "Rented_TV_Shows:") { - inRentedMovies = false; - inRentedTVShows = true; - continue; - } - - if (inRentedMovies) { - cout << line << "\n"; - } else if (inRentedTVShows) { - cout << line << "\n"; - } - } - - if (!inRentedMovies && !inRentedTVShows) { - cout << "You haven't rented any movies or TV shows yet.\n"; - } - - inFile.close(); - } - - void view_purchase() { - string userFilePath = "users/" + current_username + ".txt"; - ifstream inFile(userFilePath); - string line; - bool inPurchasedMovies = false; - bool inPurchasedTVShows = false; - - cout << "Movies you have purchased:\n"; - while (getline(inFile, line)) { - if (line == "Purchased_Movies:") { - inPurchasedMovies = true; - continue; - } - if (line == "Purchased_TV_Shows:") { - inPurchasedMovies = false; - inPurchasedTVShows = true; - continue; - } - - if (inPurchasedMovies) { - cout << line << "\n"; - } else if (inPurchasedTVShows) { - cout << line << "\n"; - } - } - - if (!inPurchasedMovies && !inPurchasedTVShows) { - cout << "You haven't purchased any movies or TV shows yet.\n"; - } - - inFile.close(); - } - - void check_dues() { - string userFilePath = "users/" + current_username + ".txt"; - ifstream inFile(userFilePath); - string line; - bool inDuesSection = false; - - // Look for dues section and print the dues for the user - while (getline(inFile, line)) { - if (line.find("Dues:") != string::npos) { - // Output dues by extracting the part after "Dues: " - cout << "Dues for " << current_username << ": " << line.substr(5) << endl; - inDuesSection = true; - break; - } - } - - if (!inDuesSection) { - cout << "No dues found for " << current_username << endl; - } - - inFile.close(); - } - -}; - -int main() { - int control; - string logged_user; - cout << "Welcome to Netflix. Press 0 if you are a user and Press 1 if you are an admin" << endl; - cin >> control; - - if (control) { - cout << "Welcome admin. Please log-in."; - if (verify_credential() != "") { // Only proceed if valid admin - Admin adminUser; - bool running = true; - while (running) { - cout << "\nAdmin Menu:" << endl; - cout << "1. Add Movie" << endl; - cout << "2. Delete Movie" << endl; - cout << "3. Add TV Show" << endl; - cout << "4. Delete TV Show" << endl; - cout << "5. Exit" << endl; - cin >> control; - string contentName; - - switch(control) { - case 1: - adminUser.addMovie(); - break; - case 2: - cout << "Enter movie name to delete: "; - cin.ignore(); - getline(cin, contentName); - adminUser.deleteMovie(contentName); - break; - case 3: - adminUser.addTVShow(); - break; - case 4: - cout << "Enter TV show name to delete: "; - cin.ignore(); - getline(cin, contentName); - adminUser.deleteTVShow(contentName); - break; - case 5: - running = false; - break; - } - } - } - } else { - cout << "Welcome user. Press 0 to sign-up and Press 1 to log-in" << endl; - cin >> control; - - if (control) { - // User logs in - logged_user = verify_credential(); - } else { - // New user sign-up - make_credential(); - logged_user = verify_credential(); - } - - // Once logged in, create or get a reference to the User object - User currentUser(logged_user); - - // User selects actions - bool running = true; - while (running) { - cout << "\nWhat would you like to do?" << endl; - cout << "1. Rent a movie or TV show" << endl; - cout << "2. Purchase a movie or TV show" << endl; - cout << "3. Return rented content" << endl; - cout << "4. View rented content" << endl; - cout << "5. View purchased content" << endl; - cout << "6. Check total charges due" << endl; - cout << "7. Exit" << endl; - cin >> control; - switch(control){ - case 1: - currentUser.start_rent(); - break; - case 2: - currentUser.purchase(); - break; - case 3: - currentUser.end_rent(); - break; - case 4: - currentUser.view_rent(); - break; - case 5: - currentUser.view_purchase(); - break; - case 6: - currentUser.check_dues(); - break; - case 7: - return 0; - } - } - } -} diff --git a/Task2/ram_d/password_db.txt b/Task2/ram_d/password_db.txt deleted file mode 100644 index c0038b6..0000000 --- a/Task2/ram_d/password_db.txt +++ /dev/null @@ -1 +0,0 @@ -ramd 3bc74a9189734d9836988a251d73a729bf55d448c06fed1291d59ddf323f159c diff --git a/Task2/ram_d/tv_show_db.txt b/Task2/ram_d/tv_show_db.txt deleted file mode 100644 index 67070b0..0000000 --- a/Task2/ram_d/tv_show_db.txt +++ /dev/null @@ -1,100 +0,0 @@ -Arrested Development|Fantasy|1|0|0|8|16|189|486 -Homeland|Sci-Fi|5|0|0|1|20|293|460 -Dark|Drama|2|0|0|7|6|141|317 -Game of Thrones|Fantasy|7|0|0|6|23|148|342 -Arrested Development|Romance|9|0|0|7|11|266|384 -Money Heist|Romance|10|0|0|3|22|259|447 -The Queen's Gambit|Sci-Fi|7|0|0|10|9|217|515 -Rick and Morty|Romance|6|0|0|7|24|263|404 -Better Call Saul|Horror|8|0|0|4|19|167|454 -The Office|Sci-Fi|3|0|0|10|10|129|397 -Mindhunter|Romance|6|0|0|9|24|176|286 -Stranger Things|Romance|3|0|0|7|21|295|435 -The Handmaid's Tale|Thriller|1|0|0|8|10|299|566 -Dark|Thriller|5|0|0|1|11|151|383 -The Handmaid's Tale|Romance|8|0|0|10|16|193|451 -Stranger Things|Thriller|6|0|0|8|19|256|360 -Loki|Sci-Fi|3|0|0|4|7|215|361 -Homeland|Comedy|8|0|0|4|23|166|416 -Fargo|Horror|7|0|0|5|8|147|442 -Chernobyl|Thriller|2|0|0|3|7|281|511 -Breaking Bad|Documentary|7|0|0|4|8|171|401 -Peaky Blinders|Drama|1|0|0|1|16|254|374 -Stranger Things|Fantasy|9|0|0|9|23|215|374 -The Umbrella Academy|Action|5|0|0|8|13|193|372 -WandaVision|Sci-Fi|5|0|0|10|19|225|343 -This Is Us|Fantasy|4|0|0|10|13|184|306 -Dark|Comedy|10|0|0|4|10|257|424 -Breaking Bad|Fantasy|9|0|0|9|11|180|333 -WandaVision|Fantasy|4|0|0|3|8|188|349 -The 100|Sci-Fi|7|0|0|5|19|180|280 -Stranger Things|Fantasy|9|0|0|8|12|209|398 -Arrested Development|Sci-Fi|3|0|0|7|19|288|499 -Friends|Sci-Fi|7|0|0|4|10|266|493 -Narcos|Horror|5|0|0|2|13|136|406 -WandaVision|Thriller|1|0|0|1|21|243|519 -Friends|Action|6|0|0|4|11|153|409 -Loki|Drama|1|0|0|1|24|247|422 -Chernobyl|Thriller|9|0|0|8|17|207|458 -Sherlock|Drama|8|0|0|5|9|128|345 -Rick and Morty|Romance|1|0|0|8|6|225|458 -The Mandalorian|Thriller|8|0|0|10|7|158|370 -Lost|Romance|4|0|0|3|7|219|386 -Mindhunter|Romance|8|0|0|7|14|224|358 -BoJack Horseman|Comedy|7|0|0|4|15|246|434 -Better Call Saul|Sci-Fi|7|0|0|6|24|109|320 -Black Mirror|Thriller|6|0|0|7|15|292|547 -Stranger Things|Horror|4|0|0|8|14|204|321 -Chernobyl|Horror|5|0|0|4|8|281|558 -Better Call Saul|Action|5|0|0|1|15|118|396 -Stranger Things|Sci-Fi|2|0|0|10|20|267|537 -WandaVision|Sci-Fi|6|0|0|8|22|135|402 -Mindhunter|Comedy|1|0|0|7|11|172|398 -The Umbrella Academy|Horror|1|0|0|3|16|257|452 -Fargo|Sci-Fi|4|0|0|8|11|196|351 -The 100|Sci-Fi|9|0|0|8|8|186|301 -WandaVision|Documentary|8|0|0|5|19|261|513 -Lost|Fantasy|1|0|0|9|6|199|491 -BoJack Horseman|Thriller|7|0|0|2|12|265|411 -The Office|Action|9|0|0|10|10|170|369 -Homeland|Sci-Fi|2|0|0|8|12|244|504 -Lost|Documentary|4|0|0|2|13|288|529 -Homeland|Documentary|10|0|0|8|6|249|399 -Money Heist|Fantasy|5|0|0|10|7|165|423 -The Witcher|Thriller|2|0|0|7|14|281|434 -The Office|Fantasy|9|0|0|5|6|103|239 -Brooklyn Nine-Nine|Sci-Fi|8|0|0|6|16|138|287 -This Is Us|Sci-Fi|1|0|0|7|12|277|387 -Loki|Comedy|6|0|0|6|8|161|302 -The Boys|Action|4|0|0|5|16|131|270 -The Queen's Gambit|Thriller|1|0|0|9|6|138|324 -Better Call Saul|Action|3|0|0|10|20|282|455 -Arrested Development|Horror|3|0|0|9|7|203|358 -The Office|Drama|2|0|0|4|10|176|449 -Dark|Action|4|0|0|1|19|287|569 -Peaky Blinders|Thriller|1|0|0|8|19|237|506 -The Marvelous Mrs. Maisel|Action|7|0|0|5|19|164|331 -House of Cards|Action|4|0|0|10|10|271|530 -The Crown|Documentary|3|0|0|3|22|209|313 -House of Cards|Romance|5|0|0|1|9|266|434 -Better Call Saul|Action|2|0|0|2|22|253|501 -Stranger Things|Comedy|6|0|0|3|15|248|455 -Breaking Bad|Drama|5|0|0|2|19|275|399 -WandaVision|Action|5|0|0|10|12|144|350 -Narcos|Sci-Fi|1|0|0|9|20|261|421 -Narcos|Comedy|8|0|0|7|6|109|321 -Brooklyn Nine-Nine|Romance|10|0|0|10|6|217|428 -The Handmaid's Tale|Thriller|3|0|0|6|24|273|483 -Fargo|Sci-Fi|1|0|0|10|15|126|358 -Brooklyn Nine-Nine|Action|6|0|0|1|18|292|554 -Mindhunter|Action|5|0|0|3|12|123|333 -Dexter|Drama|7|0|0|3|18|189|353 -Money Heist|Thriller|1|0|0|4|23|219|447 -Westworld|Thriller|3|0|0|4|6|266|402 -Fargo|Fantasy|4|0|0|4|23|121|224 -The Umbrella Academy|Fantasy|10|0|0|2|13|271|537 -Ozark|Sci-Fi|2|0|0|1|24|119|386 -BoJack Horseman|Fantasy|3|0|0|3|21|283|558 -Homeland|Action|5|0|0|8|19|204|427 -The Marvelous Mrs. Maisel|Action|10|0|0|5|11|259|377 -House of Cards|Documentary|7|0|0|1|20|259|366 \ No newline at end of file diff --git a/Task2/ram_d/users/ramd.txt b/Task2/ram_d/users/ramd.txt deleted file mode 100644 index 23ee80e..0000000 --- a/Task2/ram_d/users/ramd.txt +++ /dev/null @@ -1,4 +0,0 @@ -Rented_Movies: -Purchased_Movies: -Rented_TV_Shows: -Purchased_TV_Shows: