Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Film.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Film::Film() {
price = 0;
}

void Film::SetFilm(string name_value, string genre_value, float ratting_value, int price_value) {
void Film::SetFilm(string name_value, string genre_value, double ratting_value, int price_value) {
name = name_value;
genre = genre_value;
ratting = ratting_value;
Expand All @@ -23,7 +23,7 @@ string Film:: GetGenre() {
return genre;
}

float Film::GetRatting() {
double Film::GetRatting() {
return ratting;
}

Expand Down
6 changes: 3 additions & 3 deletions Film.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ class Film
private:
string name;
string genre;
float ratting;
double ratting;
int price;
public:
Film();
void SetFilm(string name_value, string genre_value, float ratting_value, int price_value);
void SetFilm(string name_value, string genre_value, double ratting_value, int price_value);
string GetName();
string GetGenre();
float GetRatting();
double GetRatting();
int GetPrice();
void ScanFilm();
void Print();
Expand Down
49 changes: 45 additions & 4 deletions Function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ void addfilm(string filename) {

}

void deletefilm(string filename) {
/*void deletefilm(string filename) {
cout << "Введите название фильма для удаления" << endl;
string deletename;
string archiv;
cin >> deletename;
fstream file;
int n, s = 0;
Film *film;
Film* film;
film = new Film;
file.open(filename);
if (!file) {
Expand All @@ -58,7 +58,7 @@ void deletefilm(string filename) {
//file >> name_value >> genre_value >> ratting_value >> price_value;
//film->SetFilm(name_value, genre_value, ratting_value, price_value);
s = file.tellg();
if (deletename != film->GetName())
if (deletename != film->GetName())
{
string rattingstr = to_string(film->GetRatting());
string pricestr = to_string(film->GetPrice());
Expand All @@ -67,7 +67,7 @@ void deletefilm(string filename) {
}
delete film;

} while (s < n - 4);
} while (s < n - 3);
file.close();
file.open(filename);
if (!file) {
Expand All @@ -77,6 +77,47 @@ void deletefilm(string filename) {
file << archiv;
file.close();
cout << "Фильм был успешно удален!" << endl;
}*/

void deletefilm(string filename) {
cout << "Введите название фильма для удаления" << endl;
string deletename;
cin >> deletename;
fstream file;
int n, s = 0;
const int maxsize = 20;
Film *masfilm = new Film[maxsize];
file.open(filename);
if (!file) {
cout << "Ошибка работы с файлом" << endl;
return;
}
file.seekg(0, ios_base::end);
n = file.tellg();
file.seekg(0);
int i = 0;
while (s < (n - 3)) {
file >> masfilm[i];
i++;
s = file.tellg();
}
file.close();
file.open(filename);
file.ios_base::trunc;
if (!file) {
cout << "Ошибка работы с файлом" << endl;
return;
}
//file.ios_base::trunc;
for (int j = 0; j < maxsize-1; j++) {
if ((masfilm[j].GetName() != deletename) && (masfilm[j].GetName() != "Null")) {
file << masfilm[j];
masfilm[j].Print();
}
}
delete[]masfilm;
file.close();
cout << "Фильм был успешно удален!" << endl;
}

void searchfilm(string filename) {
Expand Down
2 changes: 1 addition & 1 deletion Kinoteatr_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#include "Film.h"
#include "Function.h"
using namespace std;
bool work=true;

int main(int argc, char* argv[])
{
bool work = true;
setlocale(LC_CTYPE, "Russian");
if (argc != 2)
{
Expand Down