1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
#include "MovieType.h"
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
MovieType::MovieType(string& Title, int& Year, double long& Receipts, string& Studio, string& Stars):
m_title(Title), m_year(Year),m_receipts(Receipts), m_studio(Studio), m_stars(Stars)
{};
MovieType::MovieType():
m_title(""), m_year(-1), m_receipts(-1), m_studio(""), m_stars("")
{
};
void MovieType::ReadOneMovieFromFile(ifstream& ifs)
{
string temp;
getline(ifs,m_title);
if(m_title=="***")
return;
ifs>> m_year;
ifs>>m_receipts;
ifs.ignore(10,'\n');
getline(ifs,temp);
int pos = temp.find(',',0);
m_studio = temp.substr(0,pos);
m_stars = temp.substr(pos+2);
ifs.ignore(10,'\n');
}
void MovieType::ReadOneMovie()
{
string temp;
cout<<"Enter Title: ";
getline(cin,m_title);
cout<<"Enter Year Released: ";
cin>> m_year;
cout<<"Enter Total Gross";
cin>>m_receipts;
cin.ignore(10,'\n');
cout<<"Enter the Publising Studio and up to 3 Stars of the film/n(Make sure to seprate with commas): ";
getline(cin,temp);
int pos = temp.find(',',0);
m_studio = temp.substr(0,pos);
m_stars = temp.substr(pos+2);
cin.ignore(10,'\n');
}
void MovieType::Print(ostream& os) const
{
os=cout;
cout<<left<<setw(20)<<"Title: "<<m_title<<endl;
cout<<left<<setw(20)<<"Year Released: "<<m_year<<endl;
cout<<left<<setw(19)<<"Income: "<<"$"<<m_receipts<<endl;
cout<<left<<setw(20)<<"Studio: "<<m_studio<<endl;
cout<<left<<setw(20)<<"Stars: "<<m_stars<<endl;
}
void MovieType::setTitle()
{
string temp;
getline(cin,temp);
m_title=temp;
}
bool operator==(const MovieType& item1, const MovieType& item2)
{
return(item1.m_title==item2.m_title);
}
bool operator!=(const MovieType& item1, const MovieType& item2)
{
return(item1.m_title!=item2.m_title);
}
bool operator<=(const MovieType& item1, const MovieType& item2)
{
return(item1.m_title<=item2.m_title);
}
bool operator>=(const MovieType& item1, const MovieType& item2)
{
return(item1.m_title>=item2.m_title);
}
bool operator>(const MovieType& item1, const MovieType& item2)
{
return(item1.m_title>item2.m_title);
}
bool operator<(const MovieType& item1, const MovieType& item2)
{
return(item1.m_title<item2.m_title);
}
ostream& operator<<(ostream& os, const MovieType& Movie)
{
Movie.Print(os);
return os;
}
|