forked from DanielBillette/SoftwareProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrototype2
More file actions
162 lines (143 loc) · 2.8 KB
/
Copy pathPrototype2
File metadata and controls
162 lines (143 loc) · 2.8 KB
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
// MAIN FILE
#include <iostream>
#include <fstream>
#include <string>
#include "Form.h"
using namespace std;
void PrintEmails();
void SelectTeachers();
void ChooseRecipients();
int CreateForm();
void Transition();
string Teachers[100];
int main ()
{
Form form(CreateForm());
form.AddQuestions();
form.PrintQuestions();
Transition();
ChooseRecipients();
}
void Transition()
{
system("cls");
cout << "Next, choose who you would like to send the form to: \n\n";
}
int CreateForm()
{
int NumOfQuestions;
cout << "First, create a form.\n"
<< "How many questions would you like on your form?: ";
cin >> NumOfQuestions;
return NumOfQuestions;
}
void ChooseRecipients()
{
string line;
int count = 0;
ifstream myfile ("Teachers.txt");
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
Teachers[count] = line;
count++;
}
myfile.close();
}
else cout << "Unable to open file";
PrintEmails();
SelectTeachers();
}
void PrintEmails()
{
int count = 1;
while(Teachers[count - 1] != "\0")
{
cout << count << ": " << Teachers[count - 1];
if(count % 3 == 0)
{
cout << endl;
}
else
{
cout << "\t";
}
count++;
}
}
void SelectTeachers()
{
int UserInput = 1;
ofstream myfile ("Recipients.txt");
while(UserInput != 0)
{
cout << "\n(0 to finish) Choose a recipient: ";
cin >> UserInput;
if (myfile.is_open())
{
if(UserInput == 0)
{
cout << "\n\t[\tRecipients saved to file 'Recipients.txt'\t]\t\n\n";
}
else
{
myfile << Teachers[UserInput - 1] << endl;
cout << "\n\t[\t" << Teachers[UserInput - 1] << " added to recipients list" << "\t]\t" << endl;
}
}
else cout << "Unable to open file";
}
myfile.close();
}
// Form.h ----------------------------------------------------------------------------------------------
#pragma once
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
class Form
{
public:
Form(int);
~Form();
int GetQuestionCount() {return QuestionCount;}
void AddQuestions();
void PrintQuestions();
private:
int NumOfQuestions;
string *Questions;
int QuestionCount;
};
// Form.cpp ---------------------------------------------------------------------------------------------------
#include "Form.h"
using namespace std;
Form::Form(int num)
{
NumOfQuestions = num;
Questions = new string[num];
}
Form::~Form()
{
}
void Form::AddQuestions() // Name, Phone number, Email, Top choices you want to teach, coarses taught in past, time available, etc.
{
for(int i = 0; i < NumOfQuestions; i++)
{
cout << "Enter question " << i + 1 << ": " << endl;
cin >> Questions[i];
}
}
void Form::PrintQuestions()
{
ofstream myfile ("Form.txt");
if (myfile.is_open())
{
for(int i = 0; i < NumOfQuestions; i++)
{
myfile << Questions[i] << endl;
}
myfile.close();
}
else cout << "Unable to open file";
}