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
|
void Posting::Create_Posting(bool &check) // function to create the posting
{
char temp[1000]; //temp char array to hold user input before creating array
char display('y'); //char to run the display function if they so choose
list list;
node * current = head; // creating temp pointer for list
cin.ignore(1000,'\n');
cout << "create a title: " << endl;
cin.getline(temp, 1000); // prompt and input of post title
if (title)
delete [] title;
head -> data.title = new char [strlen(temp) + 1];
strcpy( head -> data.title, temp);
cin.ignore(1000, '\n');
cout << "add a description: " << endl;
cin.getline(temp, 1000); // prompt and input of post title
if(description)
delete [] description;
head -> data.description = new char [strlen(temp) + 1];
strcpy( head -> data.description, temp);
cin.ignore(1000, '\n');
cout << "please provide your email: " << endl; //and email
cin.getline(temp, 1000);
if(email)
delete [] email;
head -> data.email = new char [strlen(temp) + 1];
strcpy( head -> data.email, temp);
cin.ignore(1000, '\n');
if (strcmp (type, "job")== 0) // if the type of post is "job" then run this if statement to get additional info
{
cout << "What is the wage the position offers(dollars per hour): " << endl;
cin >> pay;
cout << "Location: " << endl;
cin.getline (temp, 1000);
if(location)
delete [] location;
head -> data.location = new char [strlen(temp) + 1];
strcpy( head -> data.location, temp);
cin.ignore(1000, '\n');
head -> next = NULL;
}
else if (strcmp (type, "housing") == 0) // if its "housing" run this if
{
cout << "how many sq feet is the property? : " << endl;
cin >> sqfeet;
cout << "how many rooms? :" << endl;
cin >> rooms;
cout << "how many bathrooms?: " << endl;
cin >> bathrooms;
cout << "how much is the rent?: " << endl;
cin >> rent;
cout << "What is the location of the property?: " << endl;
cin.getline (temp, 1000);
if(location)
delete [] location;
head -> data.location = new char [strlen(temp) + 1];
strcpy( head -> data.location, temp);
cin.ignore(1000, '\n');
head -> next = NULL;
}
else if (strcmp (type, "sale") == 0) //if its a "for sale" item run this one
{
cout << "what is the cost of the item: " << endl;
cin >> cost;
head -> next = NULL;
}
cout << "you have successfully created a post!" << endl;
list.count++;
cout << "\n\nwould you like to view the post you created?(y/n): " << endl;
cin >> display;
if(display == 'y' || display == 'Y')
display_post();
}
bool Posting::is_type() // function to get type of post
{
node * current = head;
char temp[1000];
bool toret = false;
cout << "What type of post are you creating? (job, housing, sale,or free): " << endl;
cin.getline(temp, 1000);
if(type)
delete [] type;
head -> data.type = new char [strlen(temp) + 1];
strcpy( head -> data.type, temp);
cin.ignore (1000, '\n');
if (strcmp (type, "job") == 0 || strcmp (type, "housing") == 0 || strcmp (type, "sale") == 0 || strcmp (type, "free") == 0) // if user input matches one of the predetermined post types the the bool is true
{
toret = true;
}
return toret;
}
|