-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsentence_driver.cpp
183 lines (150 loc) · 7.91 KB
/
sentence_driver.cpp
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#include "sentence.h"
#include "sentence.cpp"
/*********************************************************************************************
S E N T E N C E _ D R I V E R . C P P (given)
**********************************************************************************************
Name: Kevin Tudor (Z23468207)
Course: Date Structures/Algorithm Analysis (COP3530) Professor: Dr. Lofton Bullard
Due Date: 02/19/2021 Due Time: 12:00 am
Total Points: 25 Module 6: LINKED LISTS
Description: The purpose of this program is to ...
*********************************************************************************************/
using namespace std;
int main()
{
/*TEST 1 **********************************************************************************************/
cout << "****Test#1: default constructor, length, and operator<<***\n\n";
sentence you;
cout<<"\""<<you << "\"" <<" : length = "<<you.length()<< endl;
cout<<"\n****End of Test#1*******************************************\n";
cout<<endl;
/*TEST 2 **********************************************************************************************/
cout << "****Test#2: explicit-value constructor, length, and operator<<***\n\n";
sentence me("Today is a wonderful day! "); //sentence with 3 spaces at end
cout<<"me is "<<"\""<<me<<"\""<<" = "<<"\""<<"Today is a wonderful day! "<<"\""<<"\n";
cout << "The length of me is " << me.length() << "\n\n";
sentence me_to("");
cout << "me_to is " << "\"" << me_to << "\"" << " = " << "\""<< "\""<<"\n"; //sentence should be empty string
cout << "The length of me_to is " << me_to.length() << "\n\n";
sentence you_to(" ");
cout << "you_to is " << "\"" << you_to << "\"" << " = "<<"\"" <<" "<< "\"" << "\n";//sentence is one space
cout << "The length of you_to is " << you_to.length() << "\n\n";
cout << "****End of Test#2*******************************************\n";
cout<<endl;
/*TEST 3 **********************************************************************************************/
cout << "****Test#3: copy constructor, length, isEqual, and operator<<***\n\n";
sentence them = me;
cout<<"them is "<<"\""<<them<<"\""<<"\n";
cout << "The length of me is " << me.length()
<< " = The length of them is " << them.length()<<"\n";
cout <<"isEqual should equal 1 = "<< them.isEqual(me) << endl<<endl;
cout << "****End of Test#3*******************************************\n";
cout<<endl;
/*TEST 4 **********************************************************************************************/
cout<<"****TEST#4: overloaded operator= with string, and operator<<*******************\n\n";
sentence us;
us = "There are five racoons in the palm tree.";
cout<<"Testing operator = by assigning the value of "<<
"\""<<"There are five racoons in the palm tree."<<"\""<<"\n";
cout<<"The sentence us is "<< "\""<<us<<"\""<<endl<<endl;
cout<<"****End of Test#4*********************************************\n";
cout<<endl;
/*TEST 5 **********************************************************************************************/
cout<<"****TEST#5: overloaded operator= with string, isEqual, and operator<<*********\n\n";
sentence her, him;
her = "I am very happy";
him = "They are very happy";
cout << "isEqual should equal 0 = " << her.isEqual(him) << endl;
her = "";
him = "";
cout << "isEqual should equal 1 = " << her.isEqual(him) << endl;
her = " ";
him = " ";
cout << "isEqual should equal 1 = " << her.isEqual(him) << endl;
her = "";
him = " ";
cout << "isEqual should equal 0 = " << her.isEqual(him) << endl;
her = " ";
him = " ";
cout << "isEqual should equal 1 = " << her.isEqual(him) << endl;
her = " ";
him = " ";
cout << "isEqual should equal 0 = " << her.isEqual(him) << endl;
cout << "****End of Test#5*********************************************\n";
cout << endl;
/*TEST 6 **********************************************************************************************/
cout<<"****TEST#6: operator= with a string, operator+ with a sentence, and operator<<*****\n\n";
cout<<"Adding 2 sentences by adding us to the back of their. Their is the current object \n";
sentence their("Everything ");
us = "will be okay.";
cout << "us = " <<"\""<< us <<"\""<<" and length = "<<us.length()<< endl;
cout << "their = " <<"\""<< their <<"\""<<" and length = "<<their.length()<< endl;
their + us;
cout<<"their followed by us is "<< "\""<<their<< "\""<<" and length = " << their.length() << endl << endl;
cout << "us = " << "\"" << us << "\"" << " and length = " << us.length() << endl;
cout << "their = " << "\"" << their << "\"" << " and length = " << their.length() << endl;
us + their;
cout << "us followed by their is " << "\"" << us << "\"" <<" and length = "<< us.length()<< endl;
cout<<"*************************************************\n";
cout<<endl<<endl;
us = "123 456";
their = "123";
cout << "us = " << "\"" << us << "\"" << " and length = " << us.length() << endl;
cout << "their = " << "\"" << their << "\"" << " and length = " << their.length() << endl;
us + their;
cout << "us followed by their is " << "\"" << us << "\"" << "and length = " << us.length() << endl;
us = "123 456";
their = "";
cout << "us = " << "\"" << us << "\"" << " and length = " << us.length() << endl;
cout << "their = " << "\"" << their << "\"" << " and length = " << their.length() << endl;
their + us;
cout << "their followed by us is " << "\"" << their << "\"" << " and length = " << their.length() << endl<<endl;
cout << "****End of Test#6*********************************************\n\n";
/*TEST 7 **********************************************************************************************/
cout<<"****TEST#7: remove with a string without spaces, and operator<<*****\n\n";
them = "";
them.remove("123");
cout << "\"" << them << "\"" << " length of them = " << them.length() << endl;
them = "123";
them.remove("123");
cout <<"\""<< them<< "\"" << " length of them = "<<them.length()<<endl;
them = "123 abc 124 abc 123 4567";
them.remove("123");
cout << "\""<<them <<"\""<< " length of them = " << them.length() << endl;
them = "123 abc 124 abc 123 4567";
them.remove("4567");
cout <<"\""<< them <<"\"" " length of them = " << them.length() << endl;
them = "123 abc 124 abc 123 4567";
them.remove("124");
cout << "\"" << them << "\"" " length of them = " << them.length() << endl;
them.remove(" ");
cout << "\"" << them << "\"" " length of them = " << them.length() << endl;
them.remove(" ");
cout << "\"" << them << "\"" " length of them = " << them.length() << endl;
them.remove(" ");
cout << "\"" << them << "\"" " length of them = " << them.length() << endl;
them.remove(" ");
cout << "\"" << them << "\"" " length of them = " << them.length() << endl;
them.remove(" ");
cout << "\"" << them << "\"" " length of them = " << them.length() << endl<<endl;
cout << "****End of Test#7*********************************************\n";
cout << endl;
/*TEST 8 **********************************************************************************************/
cout << "****TEST#8: operator= with a sentence object and operator<<*****\n\n";
sentence h("123 456 780");
them = h;
cout << "right object = " << h << endl;
cout << "them = "<<them << endl<<endl;
cout << "****End of TEST#8****************************************\n\n";
cout << "****End of Program*********************************************\n";
/*TEST 8 end **********************************************************************************************/
/*TEST 9 **********************************************************************************************/
cout << "****TEST#9: delete all evens*****\n\n";
sentence number("1 2 3 4 5 6 7 8 9");
cout << "Initial sentence: " << number << endl;
number.Delete_All_Even();
cout << "Odd sentence: " << number << endl;
cout << "****End of TEST#9****************************************\n\n";
cout << "****End of Program*********************************************\n";
return 0;
}