Академический Документы
Профессиональный Документы
Культура Документы
#include
#include
#include
#include
<iostream>
<Windows.h>
<process.h>
<sstream>
<stdio.h>
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
do {
<<
<<
<<
<<
<<
<<
<<
<<
<<
<<
<<
"Press
"Press
"Press
"Press
"Press
"Press
"Press
"Press
"Press
"Press
"Press
case 5:
system("cls");
if (list_check == donotexist) {
cout << "List does not exist , Create the list f
irst \n";
}
else
display();
break;
case 6:
system("cls");
if (list_check == donotexist) {
cout << "List does not exist, Create the list fi
rst \n";
}
else {
addelements();
}
break;
case -1:
exit(1);
break;
default:
cout << "\n choice should be between 1 - 14 \n";
}
}
}
void createlist() {
int number;
bool repeat = false;
do {
cout << "How many entries you want to add to list : ";
cin >> number;
int_check = cin.fail();
if (cin.fail() == true) {
cout << "Entry should be an integer ranging 1-100" << en
dl;
}
cin.clear();
cin.ignore(100, '\n');
createobjectarray(number);
} while (int_check == true );
//cin >> number;
//bool test = false;
element_counter = number;
for (size_t i = 0; i < number; i++)
{
do {
cout << "Enter the id of customer " << i + 1 << " : ";
cin >> listofcustomer[i].id;
int_check = cin.fail();
if (int_check == true) {
cout << "Entry should be any integer\n\n";
cin.clear();
cin.ignore(256, '\n');
}
if (number > 1 && i > 0) {
repeat = false;
for (int j = 0; j < i; j++) {
if (listofcustomer[j].id == listofcustom
er[i].id) {
cout << "id " << listofcustomer[
i].id << " already exists at " << j + 1 << " index " << endl;
//i--;
repeat = true;
}
}
}
//i--; if (i <= 0) { i = 0; }
} while (int_check == true || repeat == true );
int mf; string s1, s2;
cout << "Enter first name : ";
cin >>s1;
cout << "Enter second name : ";
cin >> s2;
listofcustomer[i].name = s1 + " " + s2;
do {
cout << "Enter your gender :0 for male 1 for female: ";
cin >>mf;
int_check = cin.fail();
if (int_check == true) {
cout << "Entry should be an integer \n\n";
cin.clear();
cin.ignore(256,'\n');
}if (mf > 1 || mf < 0) {
cout << "Out of range choice could be either 0 o
r 1 !\n\n";
}
if (mf == 0) {
listofcustomer[i].gender = "male";
}
if (mf == 1) {
listofcustomer[i].gender = "female";
}
} while (int_check == true || mf >1 || mf < 0);
/*if (number > 1 && i > 0) {
for (int j = 0; j < i; j++) {
if (listofcustomer[j].id == listofcustomer[i].id
) {
cout << "id " << listofcustomer[i].id <<
" already exists at " << j + 1 << " index " << endl;
i--;
}
}
}*/
}
cout << "list of " << number << " numbers is created\n" << endl;
list_check = exist;
}
void deletelist() {
list_check = donotexist;
element_counter = 0;
cout << "List has been successfully deleted \n";
}
void clearlist() {
element_counter = 0;
cout << "List has been successfully cleared " << endl;
}
void copy() {
for (int i = 0; i < element_counter; i++) {
copy_list[i] = list[i];
}
cout << "list has been copid successfully " << endl;
}
void display() {
system("cls");
cout << "+-----------------------------------------------+--------------+" << endl;
cout << "|index\t|\tID\t|\tName\t\t|"<<"\tGender\t|" << endl;
cout << "+-------+---------------+-----------------------+--------------+" << endl;
for (int i = 0; i < element_counter; i++) {
cout << "|" << i + 1 << "\t|\t" << listofcustomer[i].id << "\t|\
t" <<listofcustomer[i].name << "\t|\t"<<listofcustomer[i].gender<<"\t|" << endl;
}
cout << "+-------+---------------+-----------------------+--------------+" << endl;
}
bool wrong_char(char num) {
if (num != 'Y' || num != 'y' || num != 'n' || num != 'N')
{
cout << "Wrong choice \n try again :";
return true;
}
else
return false;
}
void addelements() {
int number;
do {
cout << "How many elements you want to add to list : ";