Добавил:
bagiwow
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Программирование / си++ / 2Semestr / Lab_8 / Prog2 / Fun
.cpp//Bibl.cpp
#include "Class.h"
//-----------------------------------------------------------------------
BIBL::BIBL()
{
name = Rus("Неизвестен");
autor = Rus("Неизвестен");
price=0;
}
//-----------------------------------------------------------------------
BIBL::BIBL(string Name,string Autor,float Price)
{
name = Name;
autor = Autor;
price = Price;
}
//-----------------------------------------------------------------------
BIBL::BIBL(const BIBL& a)
{
name = a.name;
autor = a.autor;
price = a.price;
}
//-----------------------------------------------------------------------
void BIBL::Show()
{
Rus("Название : "); cout<<name<<endl;
Rus("Автор : ");cout<<autor<<endl;
Rus("Цена : ");cout<<price<<endl;
}
//-----------------------------------------------------------------------
istream& operator>>(istream& in, BIBL& B)
{
char name[30],autor[30];
in.read(name,30);
B.name = name;
in.read(autor,30);
B.autor = autor;
in.read((char*)&B.price,4);
return in;
}
//-----------------------------------------------------------------------
ostream& operator<<(ostream& out,BIBL& B)
{
out<<B.name<<endl;
out<<B.autor<<endl;
out<<B.price<<endl;
return out;
}
BIBL& BIBL::operator =(const BIBL& b)
{
if(this==&b) return *this;
name = b.name;
autor = b.autor;
price = b.price;
return *this;
}
//-----------------------------------------------------------------------
string Rus(string Str)
{
unsigned char c;
for(int i=0;i<Str.size();i++)
{
c=Str[i];
if(c>127)
{
if(c<240) c-=64;
else c-=16;
}
Str[i]=c;
}
return Str;
}
//-----------------------------------------------------------------------
void Print1(string str,db d)
{
cout<<Rus(str);
Rus(str);
if(d.empty())
Rus("\nОчередь пуста\n");
else
for(int i=0;i<d.size();i++)
cout<<d[i]<<endl;
}
//-----------------------------------------------------------------------
void Print2(string str,db d)
{
cout<<Rus(str);
iter p = d.begin();
Rus(str);
if(d.empty())
Rus("\nОчередь пуста\n");
else
for(;p!=d.end();p++)
cout<<*p<<endl;
}
//-----------------------------------------------------------------------
void AddOfFile(ifstream& in,db& d)
{
in.seekg(0,ios::end);
int Num=in.tellg()/64;
in.seekg(0,ios::beg);
BIBL b;
for(int i=0;i<Num;i++)
{
in>>b;
d.push_back(b);
}
}
//-----------------------------------------------------------------------
void Delete(db& deq,iter i,int n)
{
for(int j=0;j<n;j++)
{
if((i+j)==deq.end())
throw "\nНЕВОЗМОЖНО ВЫПОЛНИТЬ УДАЛЕНИЕ\n";
}
deq.erase(i,i+n);
}
//-----------------------------------------------------------------------
void Change(db& d1 ,iter i,int n,db& d2)
{
Delete(d1,i,n);
d1.insert(d1.end(),d2.begin(),d2.end());
}
//-----------------------------------------------------------------------