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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
delete_movie()
{
char name [25];
char name_temp [25];
char time1[25];
char time2[25];
char time3[25];
char time1_temp[25];
char time2_temp[25];
char time3_temp[25];
int response_delete;
fstream movie;
movie.open("Movies.txt",ios::in);
cout<<"======================================================================================================================" << endl;
cout<<"|SERIAL NUMBER| TIME[SHOW1] TIME[SHOW2] TIME[SHOW3] |MOVIE NAME|" << endl;
cout<<"======================================================================================================================" << endl;
int count = 0;
string line;
ifstream file("Movies.txt");
while (getline(file, line))
count++;
int i = 0;
while(!movie.eof(), i++ , i<= count)
{
movie.getline(name,25,'|');
movie.getline(time1,25,'|');
movie.getline(time2,25,'|');
movie.getline(time3,25);
cout<<" (" << i << ") " << "\t\t\t " << time1 << "\t\t\t " << time2 << "\t\t\t " << time3 << "\t\t\t " <<name << "\n";
}
ofstream temp;
temp.open("temp.txt",ios::out);
cout << endl;
cout<<"Enter the serial number of movie you want to delete: ";
cin>> response_delete;
int a = 0;
while(!movie.eof(), a++ , a <= response_delete)
{
movie.getline(name,25,'|');
movie.getline(time1,25,'|');
movie.getline(time2,25,'|');
movie.getline(time3,25);
}
while(!movie.eof())
{
movie.getline(name_temp,25,'|');
movie.getline(time1_temp,25,'|');
movie.getline(time2_temp,25,'|');
movie.getline(time3_temp,25);
if(strcmp(name_temp,name)==0)
{
continue;
}
else
{
temp<< name_temp <<'|'<< time1_temp <<'|'<< time2_temp <<'|' <<time3_temp <<'\n';
}
}
while(!movie.eof())
{
movie.getline(name_temp,25,'|');
movie.getline(time1_temp,25,'|');
movie.getline(time2_temp,25,'|');
movie.getline(time3_temp,25);
if(strcmp(name_temp,name)== 0)
{
continue;
}
else
{
temp << name_temp <<'|'<<time1_temp<<'|'<<time2_temp<<'|'<<time3_temp<<'\n';
}
}
}
update_movie()
{
char name [25];
char name_temp [25];
char time1[25];
char time2[25];
char time3[25];
char time1_temp[25];
char time2_temp[25];
char time3_temp[25];
int response_update;
fstream movie;
movie.open("Movies.txt",ios::in);
cout<<"======================================================================================================================" << endl;
cout<<"|SERIAL NUMBER| TIME[SHOW1] TIME[SHOW2] TIME[SHOW3] |MOVIE NAME|" << endl;
cout<<"======================================================================================================================" << endl;
int count = 0;
string line;
ifstream file("Movies.txt");
while (getline(file, line))
count++;
int i = 0;
while(!movie.eof(), i++ , i<= count)
{
movie.getline(name,25,'|');
movie.getline(time1,25,'|');
movie.getline(time2,25,'|');
movie.getline(time3,25);
cout<<" (" << i << ") " << "\t\t\t " << time1 << "\t\t\t " << time2 << "\t\t\t " << time3 << "\t\t\t " <<name << "\n";
}
fstream temp;
movie.open("Movies.txt",ios::in);
temp.open("temp.txt",ios::out);
cin.ignore();
cout<<"Enter the serial number of movie you want to update: ";
cin>> response_update;
int a = 0;
while(!movie.eof(), a++ , a <= response_update)
{
movie.getline(name,25,'|');
movie.getline(time1,25,'|');
movie.getline(time2,25,'|');
movie.getline(time3,25);
}
while(!movie.eof())
{
movie.getline(name_temp,25,'|');
movie.getline(time1_temp,25,'|');
movie.getline(time2_temp,25,'|');
movie.getline(time3_temp,25);
if(strcmp(name,name_temp)==0)
{
cout<<"Enter the new time for SHOW[1] : ";
cin.getline(time1,25);
cout<<"Enter the new time for SHOW[2] : ";
cin.getline(time2,25);
cout<<"Enter the new time for SHOW[3] : ";
cin.getline(time3,25);
temp << name<<'|'<<time1<<'|'<<time2<<'|'<<time3<<'\n';
}
else
{
temp << name<<'|'<<time1<<'|'<<time2<<'|'<<time3<<'\n';
}
}
temp.close();
movie.close();
movie.open("Movies.txt",ios::out);
temp.open("temp.txt",ios::in);
while(!temp.eof())
{
temp.getline(name_temp,25,'|');
temp.getline(time1,25,'|');
temp.getline(time2,25,'|');
temp.getline(time3,25);
movie << name<<'|'<<time1<<'|'<<time2<<'|'<<time3<<'\n';
}
temp.close();
movie.close();
remove("temp.txt");
cout<<"\n done !!! \n";
}
|