C++ Help on Program Please

Ok I started writing a program for my class and am stuck. Here is the assignment and the code along with it, I did write a good amount and understand what I wrote thus far but my professor isn't any hep and am having trouble moving forward, just need a push in the right direction. Assignment:Write a program that allows the user to create a data base of people, list the data base, and perform a simple search routine.
Start by creating a class called person whose interface is as follows:
class person {
private:
char* name;
public:
person(const char*);
~person();
int search(const char*);
void print();
};

The function search() prints the person’s name if the string input argument is contained anywhere within the name, and returns true. If the argument cannot be found, then function returns false.
The function print() returns the name.
Next, create a class called people whose interface is as follows:








class people {
private:
person ** array;
int length;
void prompt();
public:
people();
~people();
void menu();
void add();
void list();
void search();
};

The function prompt() displays the choices to the user as follows:
‘A’ -- Add a person
‘L’ -- List all persons
‘S’ -- Search
‘Q’ -- Quit
The function menu() prompts the user to enter the menu choice, validity checks the answer, and calls the proper member function. Exit the function if the end-of-file is entered (Quit).
The function add() prompts the user for a name and allocates a new person object from the heap space to hold this name. The address for this person is then appended to the end of the existing array, the space for which must be dynamically allocated.
The function list() calls upon the function person::print() for each person in the data base.
The function search() prompts the user to enter a string value. It then calls upon the function person::search() for each person in the data base. If the search string cannot be found in at least one person, then this function must output an appropriate error message.
A suggested main() function could be:
int main() {
people all;
all.menu();
return 0;
}



Here is my code so far:

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
#include<iostream>


using namespace std;



class person  {
   private:
     const char* name;
   public:
     person(const char*);
     ~person();
     int search(const char*);
     void print();
};

person::person(const char* newn) //person constructor
{
  name=newn;           //what you want the person to do when initialized when they get a character pointer "person Joe(newn)

}

person::~person() // person deconstructor
{
//deconstructor code here
}
class people  {
     private:
        person ** array;
        int length;
        int ppl;
        
     public:
       people();
       ~people();
         void menu();
         void add();
         void list();
         void search();
         void quit();
         void prompt();
};



// rest of the person functions here

void people::prompt() //I think this one goes here its been a while
{
     menu();
//prompt code here
}

people::people()
{
   ppl=0;
//what you want the default constructor to do
}

people::~people()
{
//people deconstructor
}

void people::menu()
{    char choice;
     cout<<"A--Add\n" ;
     
     cout<<"L--List of Names\n";
     cout<<"S--Search\n";
     cout<<"Q--Quit\n";
     cin>>choice;
     choice=toupper(choice);
     switch(choice){
                    case 'A':
                            add();
                            break;
                    case 'L':
                            list();
                            break;
                    case 'S':
                            search();
                            break;
                    case 'Q':
                            quit();
                            break;

     }
//code for menu function
}

void people::add()
{ 
        

}

void people::search()
{
     cout<<"In search";
//code for search function
}

void people::list()
{
     cout<<"in list";
}

void people::quit()
{
     cout<<"In Quit";
//code for quit function
}




int main()   {
people all;
all.menu();
system("PAUSE");
return 0;

}

Topic archived. No new replies allowed.