In c++. I have been stuck on this problem. I am not sure i keep getting errors can someone please help. The read file and write file seems to be wrong i am not sure please help! Here is the input.
In c++. I have been stuck on this problem. I am not sure i keep getting errors can someone please help. The read file and write file seems to be wrong i am not sure please help! Here is the input.
In c++. I have been stuck on this problem. I am not sure i keep getting errors can someone please help. The read file and write file seems to be wrong i am not sure please help! Here is the input.
In c++. I have been stuck on this problem. I am not sure i keep getting errors can someone please help. The read file and write file seems to be wrong i am not sure please help!
Here is the input.txt
Movie 1 1 Genre1 Movie 2 2 Genre2 Movie 3 3 Genre3 Movie 4 4 Genre4 Movie 5 5 Genre5
// Write the definition and implementation of the printCatalog function here void printCatalog(vector<movie> catalog) { for(int i=0; i<(int)catalog.size(); i++) { printMovieInfo(catalog.at(i).name, catalog.at(i).year, catalog.at(i).genre); cout << endl; } }
// Write the definition and implementation of the findMovie function here int findMovie(string n,vector<movie> catalog) { for(int i=0; i<(int)catalog.size(); i++) { if(catalog.at(i).name.compare(n)==0) { return i; } } return -1; }
// Write the definition and implementation of the addMovie function here void addMovie(string n, int y, string g, vector<movie> *catalog) { movie m; m.name = n; m.year = y; m.genre = g; catalog->push_back(m); }
// Write the definition and implementation of the removeMovie function here bool removeMovie(string n, vector<movie> *catalog) { int index = findMovie(n, *catalog); if(index!=-1) { catalog->erase(catalog->begin() + index); return true; } return false; }
// Write the definition and implementation of the movieInfo function here // You must use the following cout statement if the movie is not in the catalog: // cout << "Cannot find " << /*movie name variable identifier*/ << endl; void movieInfo(string n, vector<movie> catalog) { int index = findMovie(n, catalog); if(index!=-1) { printMovieInfo(n, catalog.at(index).year, catalog.at(index).genre); } else { cout << "Cannot find " << n << endl; } }
// Write the definition and implementation of the readFromFile function here bool readFile(string filename, vector <movie> *catalog) { ifstream in(filename); string line; if(!in.is_open()) { return false; } while(getline(in, line)) { int i = 0; movie m; stringstream ss(line); string token; while(getline(ss, token, '\t')) { if(i==0) { m.name = token; } else if(i==1) { m.year = stoi(token); } else(i==2); { m.genre = token; i = -1; } i++; } catalog->push_back(m); } in.close(); return true; }
// Write the definition and implementation of the writeToFile function here bool writeFile(string filename, vector<movie> catalog) { ofstream out(filename); if(!out.is_open()) { return false; } for(int i = 0; i <(int)catalog.size(); i++) { out << catalog.at(i).name << "\t" << catalog.at(i).year << "\t" << catalog.at(i).genre << endl; } out.close(); return true; }
#endif
Quantities that have magnitude and direction but not position. Some examples of vectors are velocity, displacement, acceleration, and force. They are sometimes called Euclidean or spatial vectors.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.