1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343
|
[/code#include <iostream>]
#include<string>
#include <stdlib.h>
using namespace std;
class insurance_category
{
static int counter;
int prdouct_id;
string level_name;
float Annual_benefit;
int Period_of_cover;
bool Cover_inpatient;
float Total_cover_for_cancer;
bool Psychiatric;
bool Maternity;
public:
void set(){
prdouct_id = ++counter;
cout << " enter level name\n";
cin >> level_name;
cout << " enter overall annual benefit\n";
cin >> Annual_benefit;
cout << "enter period of cover\n";
cin >> Period_of_cover;
cout << " cover Inpatient (0-1)\n";
cin >> Cover_inpatient;
cout << " enter Total_cover_for_cancer\n";
cin >> Total_cover_for_cancer;
cout << " enter Psychiatric (0-1)\n";
cin >> Psychiatric;
cout << "enter maternity(0-1)\n";
cin >> Maternity;
}
int get_pri() { return prdouct_id; }
void print()
{
cout << "\n Prdouct id : " << prdouct_id;
cout << "\n Level Name : " << level_name;
cout << "\n Overall annual benefit : " << Annual_benefit;
cout << "\n Period of cover : " << Period_of_cover;
cout << "\n Cover inpatient : " << Cover_inpatient;
cout << "\n Total cover for cancer : " << Total_cover_for_cancer;
cout << "\n Psychiatric : " << Psychiatric;
cout << "\n Maternity : " << Maternity;
}};
class customer
{
int id;
string name;
string address;
public:
customer(int id1, string name1, string addres1)
{
id = id1;
name = name1;
address = addres1;
}
customer(){
id = 0;
name = " ";
address = "";
};
void set_id(int i){
id = i;
}
void set_name(string n){
name = n;
}
void set_address(string a){
address = a;
}
int get_id(){ return id; }
string get_name(){ return name; }
string get_address(){ return address; }
void print(){
cout << endl << get_id() << endl << get_name() << endl << get_address() << endl;
}
};
class company: public customer
{
int lincense_num;
int counter;
insurance_category **p;
int x;
public:
company()
{
lincense_num = 0;
counter = 0;
x = 10;
p = new insurance_category*[x];
for (int i = 0; i < 10; i++)
p[i] = NULL;
}
company(int lin_num,int x1, int i1, string n1, string a1) :customer(i1, n1, a1)
{
lincense_num = lin_num;
counter = 0;
x =x1;
p = new insurance_category*[x];
for (int i = 0; i <x; i++)
p[i] = NULL;
}
void set_lincense_num(int l1)
{
lincense_num = l1;
}
void set_insurance_category()
{
if (counter < x){
p[counter] = new insurance_category;
p[counter]->set();
counter++;
}
else cout << "You may not add something \n";
}
void delet(int z)
{
/*delete p[z];
p[z] = NULL;*/
for(int i=0;i<x;i++)
{if(p[i]->get_pri()==z)
delete p[i];
p[i]=NULL;
}
}
void modify(int ob_modify)
{
p[ob_modify]->set();
for (int i = 0; i<x; i++)
{
if (p[i]->get_pri() == ob_modify)
p[i]->set();
}
}
int get_lincense_num()
{
return lincense_num;
}
void print()
{
cout << lincense_num << endl;
customer::print();
for (int i = 0; i < counter; i++){
if (p[i] != NULL)
p[i]->print();
}}};
class individual :public customer
{
int age;
int phone_number;
public:
individual(string name1, int ag1, int phone1, int id1, string addres1) :customer(id1, name1, addres1)
{
age = ag1;
phone_number = phone1;
}
individual(){
age = 0;
phone_number = 0;
};
void set_age(int ag1){
age = ag1;
}
void set_phone_number(int phone1){
phone_number = phone1;
}
int get_age(){
return age;
}
int get_phone_number(){
return phone_number;
}
void print()
{
cout << endl <<"id:"<< customer::get_id() << endl << "name: "<< customer::get_name() << endl <<"address:" <<customer::get_address() << endl <<"age:"<< get_age() << endl << "phone number:"<<get_phone_number() << endl;
}};
int main()
{
//customer
int id;
string name, address;
//indi
int Age, phone;
//company
int lincen;
//insura
int k;
int x,c;
int choice;
customer *p[2];
cout << "***** WELOCME TO OUR PROGRAM ***** ";
do {
cout << "**enter your choise 1 OR 0**\n";
cout << " 1- creat new combany \n";
cout << " 2- creat new indivduel \n";
cin >> choice;
switch (choice)
{
case 1:
{
cout << " Please enter your Name : \n";
cin >> name;
cout << " Please enter your ID : \n";
cin >> id;
cout << " Please enter your Address : \n";
cin >> address;
cout << " Please enter License Number :\n";
cin >> lincen;
cout << " Please enter Number of array :\n";
cin >> k;
/*company ob2(lincen, k, id, name, address);*/
p[0] = new company(lincen, k, id, name, address);
cout << "\n ALL INFORMATION COMPANY\n";
while (c == 1)
{
cout << " \n[1] create new insurance " << endl;
cout << "\n [2] Do you want Modify insurance ? enter 2 if you want" << endl;
cout << "\n [3] Do you want delete insurance ? enter 3 if you want" << endl;
cout << " \n[4] print all company data" << endl;
cout << "**enter your choice**" << endl;
cin >> choice;
switch (choice)
{
case 1:
/* obj.set_Insurance();*/
dynamic_cast<company*>(p[0])->set_insurance_category();
/* ob2.set_insurance_category();*/
dynamic_cast<company*>(p[0])->set_insurance_category();
break;
case 2:
cout << "enter num coulm of arrey to modify";
cin >> x;
dynamic_cast<company*>(p[0])->modify(x);
break;
case 3:
cout << "\n enter num coulm of arrey to delete";
cin >> x;
/* ob2.delet(x);*/
dynamic_cast<company*>(p[0])->delet(x);
break;
case 4:
/* ob2.print();*/
dynamic_cast<company*>(p[0])->print();
}
cout << "view the menu again?(1/0)";
cin >> c;
}
}
break;
case 2:
{
cout << "\n enter individual name";
cin >> name;
cout << "\n enter individual age ";
cin >> Age;
cout << "\n enter individual phone";
cin >> phone;
cout << "\n enter individual ID";
cin >> id;
cout << "\n enter individual ddresss";
cin >> address;
/* individual i (name, Age, phone, id, address);*/
p[1] = new individual(name, Age, phone, id, address);
/* i.print();*/
dynamic_cast<individual*>(p[1])->print();
}
break;
default:
cout << "individual number";
break;
}
}}
[code]
|