fork download
  1. #include <iostream>
  2. #include <locale.h>
  3. #include <fstream>
  4. #include <string>
  5. #include <conio.h>
  6. #include <cstdio>
  7. #include <windows.h>
  8.  
  9. using namespace std;
  10.  
  11. class client{
  12. protected:
  13. string name;
  14. int bMonth, bDay, bYear,
  15. eMonth, eDay, eYear;
  16. int cost, amount;
  17. int id;
  18. static int n;
  19. public:
  20. client::client(int fbMonth, int fbDay, int fbYear, int feMonth, int feDay, int feYear, int fcost, int fid, string fname);
  21. virtual void fAmount()=0;
  22. void printId(){printf("%2d",id);};//2
  23. void printName(){//printf("%s",name);
  24. for(int i=0;i<40-name.length();i++) cout<<" ";
  25. cout<<name;};
  26. void printAmount(){printf("%6d",amount);};//6
  27. void printCost(){printf("%5d",cost);};//5
  28. void printPeriod(){printf("%2.2d.%2.2d.%4d-%2.2d.%2.2d.%4d",bDay,bMonth,bYear,eDay,eMonth,eYear);};//21
  29. static void printTitle(){SetCaretPos(0,5);
  30. printf(" № Ф.И.О. Период страхования Упл. Страх. сумма сумма --------------------------------------------------------------------------------");};
  31. void printAll();
  32. void changeName(string newName){name=newName;};
  33. void changeCost(int newCost){cost=newCost;};
  34. void changeAmount(int newAmount){amount=newAmount;};
  35. void changeBDay(int newBDay ){bDay=newBDay;};
  36. void changeBMonth(int newBMonth ){bMonth=newBMonth;};
  37. void changeBYear(int newBYear){bYear=newBYear;};
  38. void changeEDay(int newEDay){eDay=newEDay;};
  39. void changeEMonth(int newEMonth){eMonth=newEMonth;};
  40. void changeEYear(int newEMonth){eYear=newEMonth;};
  41. static void changeN(int newN){n=newN;};
  42. static int getN(){return n;};
  43. int getId(){return id;};
  44. };
  45.  
  46. int client::n=0;
  47.  
  48. void client::printAll(){
  49. SetCursorPos(0,0);
  50. printId(); cout<<" ";
  51. printName(); cout<<" ";
  52. printPeriod(); cout<<" ";
  53. printCost(); cout<<" ";
  54. printAmount(); cout<<" ";
  55. cout<<endl;
  56. };
  57.  
  58. class adult : public client{
  59. public:
  60. adult(int fbMonth, int fbDay, int fbYear, int feMonth, int feDay, int feYear, int fcost, int fid, string fname):client(fbMonth, fbDay, fbYear, feMonth, feDay, feYear, fcost, fid, fname){fAmount();};
  61. void fAmount(){amount=cost*5;};
  62. };
  63.  
  64. class underage : public client{
  65. public:
  66. underage(int fbMonth, int fbDay, int fbYear, int feMonth, int feDay, int feYear, int fcost, int fid, string fname):client(fbMonth, fbDay, fbYear, feMonth, feDay, feYear, fcost, fid, fname){fAmount();};
  67. void fAmount(){amount=cost*7;};
  68. };
  69.  
  70. class pensioner : public client{
  71. public:
  72. pensioner(int fbMonth, int fbDay, int fbYear, int feMonth, int feDay, int feYear, int fcost, int fid, string fname):client(fbMonth, fbDay, fbYear, feMonth, feDay, feYear, fcost, fid, fname){fAmount();};
  73. void fAmount(){amount=cost*10;};
  74. };
  75.  
  76. client::client(int fbMonth, int fbDay, int fbYear, int feMonth, int feDay, int feYear, int fcost, int fid, string fname){
  77. bMonth=fbMonth; bDay=fbDay; bYear=fbYear;
  78. eMonth=feMonth; eDay=feDay; eYear=feYear;
  79. cost=fcost;
  80. id=fid;
  81. name=fname;
  82. };
  83.  
  84.  
  85.  
  86.  
  87. int main()
  88. {
  89. setlocale(LC_CTYPE,"Russian");
  90. client *p[100]; for(int i=0; i<100; i++) *p=NULL;
  91. client::changeN(0);
  92. int client_type, t_id, t_amount, t_cost, t_bMonth, t_bDay, t_bYear, t_eMonth, t_eDay, t_eYear;
  93. string s;
  94. string t_name;
  95.  
  96. ifstream infile("clients.txt");
  97. while(!infile.eof()){
  98. s=" ";
  99. t_name=" ";
  100. client_type=t_id=t_amount=t_cost=t_bMonth=t_bDay=t_bYear=t_eMonth=t_eDay=t_eYear=0;
  101. infile>>t_name; t_name+=" ";
  102. infile>>s; t_name+=s; t_name+=" ";
  103. infile>>s; t_name+=s;
  104. infile>>t_bDay; infile>>t_bMonth; infile>>t_bYear;
  105. infile>>t_eDay; infile>>t_eMonth; infile>>t_eYear;
  106. infile>>t_cost; infile>>client_type;
  107.  
  108. switch(client_type){
  109. case 1: p[client::getN()]=new adult(t_bMonth,t_bDay,t_bYear,t_eMonth,t_eDay,t_eYear,t_cost, client::getN(), t_name);
  110. break;
  111. case 2: p[client::getN()]=new underage(t_bMonth,t_bDay,t_bYear,t_eMonth,t_eDay,t_eYear,t_cost, client::getN(), t_name);
  112. break;
  113. case 3: p[client::getN()]=new pensioner(t_bMonth,t_bDay,t_bYear,t_eMonth,t_eDay,t_eYear,t_cost, client::getN(), t_name);
  114. break;
  115. default: cout<<"ERROR";
  116. }
  117. client::changeN(client::getN()+1);
  118. }
  119. infile.close();
  120.  
  121.  
  122.  
  123.  
  124. int choice=0;
  125. while(choice!=5){
  126. system("cls");
  127. client::printTitle();
  128. for(int i=0;i<client::getN();i++) p[i]->printAll();
  129. cout<<endl<<"1 - изменить, 2 - добавить, 3 - удалить, 4 - сохранить, 5 - выйти"<<endl<<"Выберите действие:"; cin>>choice;
  130. switch(choice){
  131.  
  132.  
  133. //ВЫБОР КЛИЕТА//
  134. case 1: int num;
  135. cout<<"Введите номер клиента:"; cin>>num;
  136. {
  137. int choice=0;
  138. while(choice!=5){
  139. system("cls");
  140. client::printTitle();
  141. p[num]->printAll();
  142.  
  143. cout<<endl<<"Что редактировать?"<<endl<<"1 - ФИО, 2 - уплаченная сумма, 3 -сумма страховки, 4 - период, 5 - ничего"<<endl<<"Выберите действие:"; cin>>choice;
  144. switch(choice){
  145. case 1: {string newName;
  146. cout<<"Введите новые ФИО клиента:"; cin>>newName;
  147. p[num]->changeName(newName);};
  148. break;
  149. case 2: {int newCost;
  150. cout<<"Введите новую уплаченную сумму:"; cin>>newCost;
  151. p[num]->changeCost(newCost);
  152. p[num]->fAmount();};
  153. break;
  154. case 3: {int newAmount;
  155. cout<<"Введите новую сумму страховки:"; cin>>newAmount;
  156. p[num]->changeAmount(newAmount);};
  157. break;
  158. case 4: cout<<"Что именно изменить?"<<endl<<"1 - начало страховки, 2- конец страховки";
  159. int choice;
  160. cin>>choice;
  161. switch(choice){
  162. case 1:int newBDay, newBMonth, newBYear;
  163. cout<<"Введите новый день начала страховки:"; cin>>newBDay;
  164. p[num]->changeBDay(newBDay);
  165. cout<<"Введите новый месяц начала страховки:"; cin>>newBMonth;
  166. p[num]->changeBMonth(newBMonth);
  167. cout<<"Введите новый год начала страховки:"; cin>>newBYear;
  168. p[num]->changeBYear(newBYear);
  169. break;
  170. case 2:int newEDay, newEMonth, newEYear;
  171. cout<<"Введите новый день конца страховки:"; cin>>newEDay;
  172. p[num]->changeEDay(newEDay);
  173. cout<<"Введите новый месяц конца страховки:"; cin>>newEMonth;
  174. p[num]->changeEMonth(newEMonth);
  175. cout<<"Введите новый год конца страховки:"; cin>>newEYear;
  176. p[num]->changeEYear(newEYear);
  177. break;
  178. default: break;
  179. }
  180. break;
  181. case 5: break;
  182. default:break;
  183. }
  184. }
  185. }
  186. break;
  187.  
  188.  
  189. //ДОБАВЛЕНИЕ КЛИЕНТА//
  190. case 2: client::changeN(client::getN()+1);{
  191. int client_type;
  192. string name;
  193. int bDay, bMonth,bYear,
  194. eDay, eMonth,eYear;
  195. int cost;
  196. cout<<"Выберите тип клиента(1 - взрослый, 2 - несовершеннолетний, 3 - пенсионер):";
  197. cin>>client_type;
  198. cout<<"Введите ФИО клиента:"; cin>>name;
  199. cout<<"Введите дату начала страховки(в формате дд.мм.гггг)";
  200. cin>>bDay>>bMonth>>bYear;
  201. cout<<"Введите дату конца страховки(в формате дд.мм.гггг)";
  202. cin>>eDay>>eMonth>>eYear;
  203. cout<<"Введите уплаченную сумму:"; cin>>cost;
  204. switch(client_type){
  205. case 1: p[client::getN()]=new adult(bMonth,bDay,bYear,eMonth,eDay,eYear,cost, client::getN(), name);
  206. break;
  207. case 2: p[client::getN()]=new underage(bMonth,bDay,bYear,eMonth,eDay,eYear,cost, client::getN(), name);
  208. break;
  209. case 3: p[client::getN()]=new pensioner(bMonth,bDay,bYear,eMonth,eDay,eYear,cost, client::getN(), name);
  210. break;
  211. default: break;
  212. }
  213. p[15]->printCost();
  214. }
  215. break;
  216.  
  217.  
  218. case 3: //delClient();
  219. break;
  220.  
  221.  
  222. case 4: //save();
  223. break;
  224.  
  225.  
  226. case 5: break;
  227. }
  228. }
  229.  
  230.  
  231.  
  232. getch();
  233. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:5:19: fatal error: conio.h: No such file or directory
 #include <conio.h>
                   ^
compilation terminated.
stdout
Standard output is empty