Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <conio.h>
- #include <iomanip>
- #include <fstream>
- using namespace std;
- class TOVAR
- {
- int Prof;
- void Profit();
- public:
- char name[15];
- double prise;
- int supplier;
- int deliverGoods;
- double PRN;
- int Profit_out();
- TOVAR();
- TOVAR(char p_name[15], int p_prise, int p_supplier, int p_deliverGoods, double p_PRN);
- ~TOVAR();
- };
- TOVAR::TOVAR()
- {
- strcpy(name, "");prise=0; supplier=0;deliverGoods=0;PRN=0;
- }
- TOVAR::TOVAR(char p_name[15], int p_prise, int p_supplier, int p_deliverGoods, double p_PRN)
- {
- strcpy(name, p_name); prise=p_prise; supplier=p_supplier; deliverGoods=p_deliverGoods; PRN=p_PRN;
- }
- TOVAR::~TOVAR()
- {
- cout << "DELETE...";
- }
- void TOVAR::Profit()
- {Prof = prise*supplier*deliverGoods*PRN;}
- int TOVAR::Profit_out()
- {Profit();
- return Prof;
- }
- int main(){
- TOVAR Number1;
- cout<<"Info nomer 1"<<endl;
- cout<<"Name: "<<Number1.name<<" "<<" Price- "<<Number1.prise<<" supplier- "<<Number1.supplier<<" deliverGoods- "<<Number1.deliverGoods<<" PRN- "<<Number1.PRN<<endl;
- TOVAR Number2("Moloko", 100, 10, 5, 1);
- cout<<"Info nomer 2"<<endl;
- cout<<"Name: "<<Number2.name<<" "<<" Price- "<<Number2.prise<<" supplier- "<<Number2.supplier<<" deliverGoods- "<<Number2.deliverGoods<<" PRN- "<<Number2.PRN<<endl;
- TOVAR Number3("Xleb", 50, 5, 3, 1);
- cout<<"Info nomer 3"<<endl;
- cout<<setw(15)<<" Name "<<setw(15)<<" Price "<<setw(15)<<" Profit "<<endl;
- cout<<setw(15)<<Number3.name <<setw(15)<<Number3.prise<<setw(15)<<Number3.Profit_out()<<endl;
- TOVAR Number4("Pechenie", 75, 7, 4, 1);
- cout<<"Info nomer 4"<<endl;
- cout<<setw(15)<<" Name "<<setw(15)<<" Price "<<setw(15)<<" Profit "<<endl;
- cout<<setw(15)<<Number4.name <<setw(15)<<Number4.prise<<setw(15)<<Number4.Profit_out()<<endl;
- TOVAR Number5("Kefir", 60, 8, 3, 1);
- cout<<"Info nomer 5"<<endl;
- cout<<setw(15)<<" Name "<<setw(15)<<" Price "<<setw(15)<<" Profit "<<endl;
- cout<<setw(15)<<Number5.name <<setw(15)<<Number5.prise<<setw(15)<<Number5.Profit_out()<<endl;
- TOVAR mas[5];
- char zagl[4][10] = {"name", "prise", "supplier", "PRN"};
- const char* name_of_file ="D:/huy.txt";
- ifstream fin;
- fin.open(name_of_file);
- if(!fin.is_open())
- {
- cout << endl;
- cout << endl;
- cout << "-----------------------------Can't open file!!!-----------------------------" << endl;
- }
- else
- {
- for(int i=0;i<5;i++)
- {
- fin >> mas[i].name;
- fin >> mas[i].prise;
- fin >> mas[i].supplier;
- fin >> mas[i].PRN;
- }
- if(!fin.good())
- {
- cout << endl;
- cout << endl;
- cout << "--------------------------FILE HAS BEEN OPENED!-----------------------------" << endl; }
- fin.close();
- }
- for (int i=0; i<4; i++) cout << setw(15)<<zagl[i];
- cout << endl; cout << endl;
- for(int i=0;i<5;i++)
- {
- cout << setw(15)<< mas[i].name;
- cout << setw(15)<< mas[i].prise;
- cout << setw(15)<< mas[i].supplier;
- cout << setw(15) << mas[i].Profit_out();
- cout << endl;
- }
- TOVAR mas_2[5]={ TOVAR ("Moloko", 100, 10, 5, 1), TOVAR ("Xleb", 50, 5, 3, 1), TOVAR ("Pechenie", 75, 7, 4, 1), TOVAR ("Kefir", 60, 8, 3, 1), };
- cout << endl;
- cout << endl;
- cout << setw(50)<<"----------------------------------------------------------------------------";
- cout << endl;
- cout << endl;
- char zagl2[4][10] = {"name", "prise", "supplier", "PRN"};
- for (int i=0; i<4; i++) cout << setw(15)<< zagl2[i];
- cout << endl;
- cout << endl;
- for(int i=0;i<5;i++)
- {
- cout << setw(15)<< mas[i].name;
- cout << setw(15)<< mas[i].prise;
- cout << setw(15)<< mas[i].supplier;
- cout << setw(15) << mas[i].PRN;
- cout << endl;}
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement