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
|
#include "main.h"
using namespace std;
Posting::Posting()
{
int size(0);
int cost(0);
description = new char[size];
title = new char[size];
type = new char[size];
int sq_feet(0);
int rooms(0);
int rent(0);
location = new char[size];
email = new char[size];
int pay(0);
cout <<" objects are being created" << endl;
}
void Posting::Create_Posting(Posting *post_ptr, Posting *type, Posting *title, Posting *description, Posting *email)
{
char again('y');
char temp[1000];
cout << "Would you like to create a new posting? (y/n): " << endl;
cin >> again;
while (again == 'y' || again == 'Y')
{
if(is_type(post_ptr, type))
{
cout << "Create a title: " << endl;
cin.getline(temp, 1000);
cin.ignore(1001,'\n');
post_ptr -> title = new char[strlen (temp) + 1];
strcpy(post_ptr -> title, temp);
cout << "add a description: " << endl;
cin.getline(temp, 1000);
cin.ignore(1001, '\n');
post_ptr -> description = new char[strlen (temp) + 1];
strcpy (post_ptr -> title, temp);
}
}
}
bool Posting::is_type( Posting *post_ptr, Posting *type)
{
char temp[100];
cout << "What type of post are you creating? (job, housing, for sale, free stuff): " << endl;
cin >> temp;
post_ptr -> type = new char[strlen (temp) + 1];
strcpy( post_ptr -> type, temp);
if (strcmp (post_ptr -> type, "job") || strcmp (post_ptr -> type, "housing") || strcmp (post_ptr -> type, "for sale") || strcmp (post_ptr -> type, "free stuff"))
return true;
return false;
}
Posting::~Posting()
{
delete [] description;
delete [] title;
delete [] type;
delete [] location;
delete [] email;
cout << "objects are being deleted" << endl;
}
|