Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <iostream>
- #include "./netflix.h"
- #include "./movie.h"
- /*
- using std::cout;
- using std::endl;
- using std::cin;
- using std::string;
- using std::fstream;
- using std::ofstream;
- using std::ifstream;*/
- using namespace std;
- movie enter_movie(int);
- void find_movie();
- int main(){
- //Find the number of lines in the thing
- //(Check how many they want to add)
- //Make the netflix object with the array
- char current_num[256];
- for(int f=0;f<256;f++){
- current_num[f]='\0';
- }
- ofstream database;
- //getline(myfile,bl,'|')
- database.open("netflix.dat",fstream::app);//for writing
- //database<<"\n";
- ifstream read_data;
- read_data.open("netflix.dat",ifstream::in);
- if(read_data.is_open()){
- while(read_data.good()){
- read_data.getline(current_num,100,'|');
- for(int d=0;d<20;d++)
- cout<<current_num[d]<<endl;;
- }
- database.close();
- }
- //check_length();
- int movies2add;
- int enterorfind;
- cout<<"Do you want to enter a movie to the database or find a movie to rent?";
- cout<<" (1 - enter, 2 - find, or 0 - exit) ";
- cin>>enterorfind;
- if(enterorfind==1){
- cout<<endl<<"How many movies do you want to enter to the database? ";
- cin>>movies2add;
- //netflix net_data;
- movie to_add = enter_movie(movies2add);
- }
- if(enterorfind==2){
- //Find movie
- find_movie();
- }
- if(enterorfind==0){
- //Quit
- return 0;
- }
- }
- movie enter_movie(int i){
- string movie_name, movie_rating, movie_castmem;
- int movie_stars, movie_castnum, movie_copies, movies2add;
- string *cast; //This is a dynamic array of strings
- movie temp_movie;
- for(int i=0;i<movies2add;i++){
- cout<<"Enter the name of your movie: ";
- cin>>movie_name;
- temp_movie.set_name(movie_name);
- cout<<"How many stars? ";
- cin>>movie_stars;
- temp_movie.set_stars(movie_stars);
- cout<<"How many cast members? ";
- cin>>movie_castnum;
- temp_movie.set_num_cast(movie_castnum);
- cast = new string[movie_castnum];
- for(int j=0;j<movie_castnum;j++){
- cout<<"Enter cast member "<<j+1<<": ";
- cin>>movie_castmem;
- cast[j]=movie_castmem;
- }
- temp_movie.set_cast(cast);
- cout<<"Enter the movie rating: ";
- cin>>movie_rating;
- temp_movie.set_rating(movie_rating);
- cout<<"How many copies of this movie: ";
- cin>>movie_copies;
- temp_movie.set_copies(movie_copies);
- cout<<endl;
- cout<<"Added to the database!"<<endl<<endl;
- return temp_movie;
- }
- }
- void find_movie(){
- string movie_name, movie_rating, movie_castmem;
- int movie_stars, movie_castnum, search_type, movie_copies, movies2add;
- cout<<"Do you want to find movies based on: 1 - name, 2 - number of stars, 3 - specific cast member, or 4 - rating)? ";
- cin>>search_type;
- switch(search_type){
- case 1:
- cout<<endl<<"What is the title? ";
- cin>>movie_name;
- case 2:
- cout<<endl<<"How many stars? ";
- cin>>movie_stars;
- case 3:
- cout<<endl<<"Who is the cast member? ";
- cin>>movie_castmem;
- case 4:
- cout<<endl<<"What is the rating? ";
- cin>>movie_rating;
- default:
- cout<<endl<<"That isn't an option..."<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement