fork download
  1. #include <iostream>
  2. #include <locale.h>
  3. #include <fstream>
  4. #include <string>
  5. #include <conio.h>
  6.  
  7.  
  8. using namespace std;
  9.  
  10.  
  11. class client{
  12. protected:
  13. char name[50];
  14.  
  15. int bMonth, bDay, bYear,
  16. eMonth, eDay, eYear;
  17. int amount, cost;
  18. int id;
  19. public:
  20. client::client(int fbMonth, int fbDay, int fbYear, int feMonth, int feDay, int feYear, int fcost, int fid);
  21. virtual void fAmount()=0;
  22. void printName(){cout<<name;};
  23. void printId(){cout<<id;};
  24. void printAmount(){cout<<amount;};
  25. void printCost(){cout<<cost;};
  26. void printPeriod(){cout<<bDay<<'.'<<bMonth<<'.'<<bYear<<'-'<<eDay<<'.'<<eMonth<<'.'<<eYear;};
  27. void printFromFile();
  28. };
  29.  
  30.  
  31.  
  32. class adult : public client{
  33. public:
  34. adult(int fbMonth, int fbDay, int fbYear, int feMonth, int feDay, int feYear, int fcost, int fid):client(fbMonth, fbDay, fbYear, feMonth, feDay, feYear, fcost, fid){};
  35. void fAmount(){amount=cost*5;};
  36. };
  37.  
  38. class underage : public client{
  39. public:
  40. underage(int fbMonth, int fbDay, int fbYear, int feMonth, int feDay, int feYear, int fcost, int fid):client(fbMonth, fbDay, fbYear, feMonth, feDay, feYear, fcost, fid){};
  41. void fAmount(){amount=cost*7;};
  42. };
  43.  
  44. class pensioner : public client{
  45. public:
  46. pensioner(int fbMonth, int fbDay, int fbYear, int feMonth, int feDay, int feYear, int fcost, int fid):client(fbMonth, fbDay, fbYear, feMonth, feDay, feYear, fcost, fid){};
  47. void fAmount(){amount=cost*10;};
  48. };
  49.  
  50. client::client(int fbMonth, int fbDay, int fbYear, int feMonth, int feDay, int feYear, int fcost, int fid){
  51. bMonth=fbMonth; bDay=fbDay; bYear=fbYear;
  52. eMonth=feMonth; eDay=feDay; eYear=feYear;
  53. cost=fcost;
  54. id=fid;
  55. }
  56.  
  57.  
  58.  
  59.  
  60. int main()
  61. {
  62. setlocale(LC_CTYPE,"Russian");
  63. client *p[100]; int i=0;
  64. int client_type, t_id, t_amount, t_cost, t_bMonth, t_bDay, t_bYear, t_eMonth, t_eDay, t_eYear;
  65. char s[50];
  66. char t_name[50];
  67. ifstream infile("clients.txt");
  68. while(!infile.eof()){
  69. strcpy(s, " ");
  70. strcpy(t_name, " ");
  71. client_type=t_id=t_amount=t_cost=t_bMonth=t_bDay=t_bYear=t_eMonth=t_eDay=t_eYear=0;
  72.  
  73. infile>>s;
  74. for(int i=0;i<strlen(s);i++) t_name[i]=s[i];
  75. strcat(t_name, " ");
  76. infile>>s;
  77. strcat(t_name, s);
  78. strcat(t_name, " ");
  79. infile>>s;
  80. strcat(t_name, s);
  81.  
  82. infile>>t_bDay; infile>>t_bMonth; infile>>t_bYear;
  83. infile>>t_eDay; infile>>t_eMonth; infile>>t_eYear;
  84. infile>>t_cost; infile>>client_type;
  85.  
  86. switch(client_type){
  87. case 1: p[i]=new adult(t_bMonth,t_bDay,t_bYear,t_eMonth,t_eDay,t_eYear,t_cost, i);
  88. break;
  89. case 2: p[i]=new underage(t_bMonth,t_bDay,t_bYear,t_eMonth,t_eDay,t_eYear,t_cost, i);
  90. break;
  91. case 3: p[i]=new pensioner(t_bMonth,t_bDay,t_bYear,t_eMonth,t_eDay,t_eYear,t_cost, i);
  92. break;
  93. default: cout<<"ERROR";
  94. }
  95.  
  96.  
  97. i++;
  98. }
  99.  
  100. infile.close();
  101. getch();
  102. }
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