#include <iostream>
#include <string>
#include <fstream>
#include <conio.h>
using namespace std;
struct TarifPlan
{
private:
float zalishok;
public:
float sms;
float zena1;
float zena2;
void setzalishok ()
{
zalishok = 15;
}
int getzalishok ()
{
//cout << zalishok << endl;
return zalishok;
}
void popovnenya ()
{
zalishok += 20;
}
void popovnenya (int x)
{
zalishok += x;
}
void abouttarifplan()
{
cout << " Vartist sms - " << sms << "\n Zena rozmovu v sereduni mereshi - "<< zena1 << "\n Zena rozmovu z nomeramu inshih operatoriv - " << zena2 << "\n Zalishok = "<< zalishok << endl;
}
TarifPlan ()
{
ifstream filee;
filee.open("tarifplan.txt", fstream::in);
filee >> sms;
filee >> zena1;
filee >> zena2;
}
};
class Abonent
{
protected:
int nomer;
string result;
string name;
TarifPlan plan;
//------------------------------------------------------------------------------------------------------------------
public:
Abonent ()
{
ifstream filee;
filee.open("abonent.txt", fstream::in);
filee >> nomer;
filee >> result;
filee >> name;
}
void aboutabonent()
{
cout << " nomer - " << nomer << "\n result - "<< result << "\n name - " << name << endl;
plan.abouttarifplan();
}
void popovnenya()
{
plan.popovnenya();
}
void popovnenya(int x)
{
plan.popovnenya(x);
}
void setzalishok()
{
plan.setzalishok();
}
};
class Naslidok : public Abonent
{
public:
void zchituvanua(string imya)
{
ifstream filee;
filee.open(imya, fstream::in);
filee >> plan.sms;
filee >> plan.zena1;
filee >> plan.zena2;
}
void choosingtf()
{
popovnenya(-10);
}
friend void countsms(Naslidok &value);
};
int zukl(float value1, float value2)
{
int count = 0;
while (value1 != 0 )
{
value1-=value2;
if(value1 >= 0)
count++;
else
break;
}
//cout << count << endl;
return count;
}
void countsms(Naslidok &value)
{
float x = value.plan.getzalishok();
cout << " Count of sms - " << zukl(x,value.plan.sms) << endl;
cout << " Count of zena1 - " << zukl(x,value.plan.zena1) << endl;
cout << " Count of zena2 - " << zukl(x,value.plan.zena2) << endl;
//cout << " Count of sms - " << count<< endl;
}
Naslidok naslidok;
void menu()
{
char point;
cout << "Viberite tarifplan: 1, 2, 3, 4 or 5 : ";
cin >> point;
switch (point)
{
case '1':
naslidok.zchituvanua("tarifplan.txt");
break;
case'2':
naslidok.zchituvanua("tarifplan2.txt");
break;
case '3':
naslidok.zchituvanua("tarifplan3.txt");
break;
case '4':
naslidok.zchituvanua("tarifplan4.txt");
break;
case '5':
naslidok.zchituvanua("tarifplan5.txt");
break;
}
}
int main()
{
naslidok.setzalishok();
menu();
char znak, znak2;
do
{
cout << "Vvedite znak - " << endl;
cout << "1 - stan rahunku" << endl;
cout << "2 - popovnenya na 20" << endl;
cout << "3 - popovnenya na x" << endl;
cin >> znak;
switch (znak)
{
case '1':
naslidok.aboutabonent();
countsms(naslidok);
break;
case '2':
naslidok.popovnenya();
naslidok.aboutabonent();
break;
case '3':
int x;
cout << "Vvedite x" << endl;
cin >> x;
naslidok.popovnenya(x);
naslidok.aboutabonent();
break;
default: puts("Invalid input"); return 0;
}
cout << "Press # if you want to choose the tarifplan" << endl;
cin >> znak2;
if (znak2=='#')
{
menu();
naslidok.choosingtf();
}
}while(getch()!=27);
system ("pause");
return 0;
}
Czemu nazwy zmiennych i funkcji nie są na chińskim? Skoro da się utrudnić to robić na maksa!
Jak nie podasz, jaki jest błąd to w żaden sposób nie da ci się pomóc. W kodzie używasz polików, o jakich nic nie napisałeś ani ich nie udostępniłeś.
Moim zdaniem próbujesz wykorzystać cudzy kod jako swój.
Mogłeś dodać jeszcze tekst psalmów z Biblii napisanych po hebrajsku, dałoby nam to tyle samo zrozumienia dla problemu.
O co chodzi z tym błąd taśmy 38
?
Gdzie masz ten błąd i jak ten błąd jest opisany dokładnie? Bo jak wrzucam ten kod w "online C++ compiler" ( https://www.onlinegdb.com/online_c++_compiler ) i klikam run
to się normalnie uruchamia i wydaje się, że działa.
Google sugeruje, że kod napisany jest po rosyjsku z alfabetem łacińskim (przepuściłem literały przez google traslate)
@Maksim kod piszemy po angielsku, nieważne jakiej narodowości jest autor, jakby dobrze poszukać to upominamy też polaków, żeby pisali po angielsku.
Jest na to więcej niż jeden powód:
- Czytelnik nieznający danego języka, nie będzie miał problemu czytać kodu (angielski powinien być znany każdemu w IT) - zadając pytanie na polskim forum doświadczasz tego problemu.
- Biblioteki są pisane po angielsku, ergo używanie biblioteki w kodzie pisanym w języku narodowym, daje dwujęzyczne spaghetti
- Angielski ma właściwości (minimalna fleksja, ścisła gramatyka), które czynią ten język idealnym dla programowania.
Nawet informację o błędzie powinieneś wklejać po angielsku.