aboutsummaryrefslogtreecommitdiff
path: root/CST116F2021-Lab7
diff options
context:
space:
mode:
authorBenjamin Schroeder <[email protected]>2021-11-12 18:17:34 -0800
committerBenjamin Schroeder <[email protected]>2021-11-12 18:17:34 -0800
commitb21aaf4b4e60d28552856ae397535db5d84b999f (patch)
treea47cb6415210b274081c2a555ecc9f2dca427347 /CST116F2021-Lab7
parentAdd online IDE url (diff)
downloadcst116-lab7-bensprogramma-b21aaf4b4e60d28552856ae397535db5d84b999f.tar.xz
cst116-lab7-bensprogramma-b21aaf4b4e60d28552856ae397535db5d84b999f.zip
.cpp and .txt files
Diffstat (limited to 'CST116F2021-Lab7')
-rw-r--r--CST116F2021-Lab7/CST116F2021-Lab7.cpp20
-rw-r--r--CST116F2021-Lab7/CST116F2021-Lab7.vcxproj2
-rw-r--r--CST116F2021-Lab7/CST116F2021-Lab7.vcxproj.filters2
-rw-r--r--CST116F2021-Lab7/CST116F2021-Lab7_Schroeder.cpp158
4 files changed, 160 insertions, 22 deletions
diff --git a/CST116F2021-Lab7/CST116F2021-Lab7.cpp b/CST116F2021-Lab7/CST116F2021-Lab7.cpp
deleted file mode 100644
index 77b01eb..0000000
--- a/CST116F2021-Lab7/CST116F2021-Lab7.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-// CST116F2021-Lab7.cpp : This file contains the 'main' function. Program execution begins and ends there.
-//
-
-#include <iostream>
-
-int main()
-{
- std::cout << "Hello World!\n";
-}
-
-// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
-// Debug program: F5 or Debug > Start Debugging menu
-
-// Tips for Getting Started:
-// 1. Use the Solution Explorer window to add/manage files
-// 2. Use the Team Explorer window to connect to source control
-// 3. Use the Output window to see build output and other messages
-// 4. Use the Error List window to view errors
-// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
-// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
diff --git a/CST116F2021-Lab7/CST116F2021-Lab7.vcxproj b/CST116F2021-Lab7/CST116F2021-Lab7.vcxproj
index 5aec3b1..01ed0a3 100644
--- a/CST116F2021-Lab7/CST116F2021-Lab7.vcxproj
+++ b/CST116F2021-Lab7/CST116F2021-Lab7.vcxproj
@@ -139,7 +139,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="CST116F2021-Lab7.cpp" />
+ <ClCompile Include="CST116F2021-Lab7_Schroeder.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/CST116F2021-Lab7/CST116F2021-Lab7.vcxproj.filters b/CST116F2021-Lab7/CST116F2021-Lab7.vcxproj.filters
index e6b507e..da06724 100644
--- a/CST116F2021-Lab7/CST116F2021-Lab7.vcxproj.filters
+++ b/CST116F2021-Lab7/CST116F2021-Lab7.vcxproj.filters
@@ -15,7 +15,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="CST116F2021-Lab7.cpp">
+ <ClCompile Include="CST116F2021-Lab7_Schroeder.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
diff --git a/CST116F2021-Lab7/CST116F2021-Lab7_Schroeder.cpp b/CST116F2021-Lab7/CST116F2021-Lab7_Schroeder.cpp
new file mode 100644
index 0000000..a3ea111
--- /dev/null
+++ b/CST116F2021-Lab7/CST116F2021-Lab7_Schroeder.cpp
@@ -0,0 +1,158 @@
+// CST116F2021-Lab7.cpp : This file contains the 'main' function. Program execution begins and ends there
+// ...from : Lab7_Schroeder.cpp
+
+
+#include <iostream>
+#include<iomanip>
+#include<string>
+#define _CRT_SECURE_NO_WARNINGS
+#pragma warning(disable:4996)
+
+using namespace std;
+
+#define ARRAY_SIZE 100
+void menu(int&);
+void readData(int&);
+void printData(int&);
+void findString(int&);
+void deleteString(int&);
+string stringArray[ARRAY_SIZE]{};
+int item = 0;
+
+int main()
+{
+ menu(item);
+
+}
+
+
+void menu(int& item)
+{
+ int menuChoice = 0;
+ cout << "MENU: 1) Add a string 2) Print out 3) Find subString 4) Delete a string 5) Exit ...";
+
+ cin >> menuChoice;
+ if (cin.fail())
+ {
+ menuChoice = 0;
+ cout << "(you have to enter: 1,2,3,4 or 5 (start the program again))";
+ cin >> menuChoice;
+ }
+ else
+ {
+ while ((menuChoice < 1 || menuChoice >5))
+ {
+ cout << "(enter: 1,2,3,4,or 5) ";
+ cin >> menuChoice;
+ }
+ }
+
+
+ switch (menuChoice)
+ {
+ case 1:
+ {
+ readData(item);
+ break;
+ }
+ case 2:
+ {
+ printData(item);
+ break;
+ }
+ case 3:
+ {
+ findString(item);
+ break;
+ }
+ case 4:
+ {
+ deleteString(item);
+ break;
+ }
+ case 5:
+ {
+ cout << "Thankyou, Goodbye!!\n\n";
+ break;
+ }
+
+ }
+}
+
+void readData(int& item)
+{
+
+ string tempString;
+ cout << "Type in your string to add: ";
+ getline(cin >> ws, tempString);
+ stringArray[item] = tempString;
+ item++;
+ menu(item);
+}
+
+void printData(int& item)
+{
+ cout << "\n\nHere are your string entries...\n";
+ for (int i = 0; i < item; i++)
+ {
+ cout << i + 1 << ".\t" << stringArray[i] << "\n";
+ }
+ cout << "\n\n";
+ menu(item);
+}
+
+void findString(int& item)
+{
+ string temp = " ";
+ cout << "Enter the subString you want to search for: ";
+ cin >> temp;
+
+ string subString{ temp };
+
+ for (int k = 0; k <= item - 1; k++)
+ {
+ int i = 0, j = 0;
+ while ((subString[i] != stringArray[k][j]) && (j < stringArray[k].size()))
+ {
+ j++;
+ }
+
+ if (subString[i] == stringArray[k][j])
+ while ((subString[i] == stringArray[k][j]) && (i < subString.size()) && j < stringArray[k].size())
+ {
+ i++;
+ j++;
+ }
+
+ if (i == subString.size())
+ cout << "\tSubstring '" << subString << "' was found in string: " << k + 1 << "\n";
+ else
+ cout << "\t...not found in string: " << k + 1 << "\n";
+ }
+ cout << "\n\n";
+
+ menu(item);
+}
+
+void deleteString(int& item)
+{
+ int temp = 0;
+ cout << "Which string (1 to " << item << ") would you like to delete? ";
+ cin >> temp;
+ int i = temp - 1;
+ stringArray[i] = {};
+ for (i; i <= item - 1; i++)
+ {
+ stringArray[i] = stringArray[i + 1];
+
+ }
+ item--;
+ cout << "\n\n";
+ menu(item);
+
+}
+
+
+
+
+