add projects 6 and 7
This commit is contained in:
parent
f789abddb2
commit
07b4ea9822
12 changed files with 748 additions and 0 deletions
100
Project6/Project6.cpp
Normal file
100
Project6/Project6.cpp
Normal file
|
@ -0,0 +1,100 @@
|
|||
// Corey Williams
|
||||
// COP3530 01Z
|
||||
// Project 6
|
||||
|
||||
/*
|
||||
Create an application that allows user to build a Queue of Circle Elements.
|
||||
The Queue must be built using a Linked List (i.e., refer to Linked List Implementation, Figure 4.10 pp. 143 - 144 [uses C++ template; Figure 4.13 uses the template]).
|
||||
|
||||
The application must be menu controlled and provide the following.
|
||||
* Allow insertion of a "Circle" object/structure in the Queue data structures.
|
||||
* Allow display of all elements from Queue data structure by Invoking a method/function "DisplayQueue" (uses "DeQueue" method).
|
||||
* Allow for deletion of the Queue
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include <iostream>
|
||||
#include "genQueue.h"
|
||||
#include "circle.h"
|
||||
#include <string>
|
||||
|
||||
void enterQueueElements(Queue<Circle>& q) { //queue is passed in by reference in order to remain persistent between main and function calls
|
||||
system("cls");
|
||||
string r = "0"; //Takes string so that user input can be processed regardless of validity
|
||||
|
||||
//Greeting/instruction text
|
||||
cout << "1. Enter Queue Elements" << endl;
|
||||
cout << "=======================" << endl;
|
||||
cout << "Input a positive number to add a circle with that radius to the queue"
|
||||
<< endl << "or enter q to exit back to the main menu" << endl << endl;
|
||||
|
||||
//Loops until exit condition is input by user
|
||||
while (r != "q") {
|
||||
cout << "Input: ";
|
||||
cin >> r;
|
||||
|
||||
if (r == "q" or r == "Q") { return; }
|
||||
else {
|
||||
try { //try block encapsulates attempt to cast string to double
|
||||
Circle tmp(stod(r)); //instantiates circle with user-input radius
|
||||
q.enqueue(tmp); //adds circle to queue
|
||||
cout << "Circle of radius " << r << " added to queue." << endl;
|
||||
}
|
||||
catch (...) { //catches when user input is not able to be used as a numeric input
|
||||
cout << "Not a valid entry, please try again. ";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void displayQueueElements(Queue<Circle> q) { //receives a copy of the queue from main so that elements can be dequeued for output while leaving the original queue intact
|
||||
cout << endl << "Elements:" << endl << endl;
|
||||
if (q.isEmpty()) { cout << "There are no elements in queue. "; }
|
||||
while (!q.isEmpty()) {
|
||||
Circle tmp = q.dequeue();
|
||||
cout << "Radius: " << tmp.getRadius() << endl;
|
||||
cout << "Area: " << tmp.calculateArea() << endl << endl;
|
||||
}
|
||||
system("pause");
|
||||
}
|
||||
|
||||
void deleteCurrentQueue(Queue<Circle>& q) { //receives reference to main function's queue and deletes all elements
|
||||
q.clear();
|
||||
cout << endl << endl;
|
||||
cout << "The queue has been cleared. ";
|
||||
system("pause");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
Queue<Circle> cirQueue;
|
||||
string menuChoice = "0";
|
||||
|
||||
//Main Menu - reads string from user and parses for menu selection
|
||||
//Loops until exit condition is input by user
|
||||
while (menuChoice != "4") {
|
||||
menuChoice = "0";
|
||||
system("cls");
|
||||
|
||||
cout << "Main Menu" << endl
|
||||
<< "1. Enter Queue Elements" << endl
|
||||
<< "2. Display Queue Elements" << endl
|
||||
<< "3. Delete Current Queue" << endl
|
||||
<< "4. Exit Program" << endl
|
||||
<< endl << "Choose an option (1-4): ";
|
||||
cin >> menuChoice;
|
||||
|
||||
if (menuChoice == "1") { enterQueueElements(cirQueue); }
|
||||
else if (menuChoice == "2") { displayQueueElements(cirQueue); }
|
||||
else if (menuChoice == "3") { deleteCurrentQueue(cirQueue); }
|
||||
else if (menuChoice == "4") { return 0; }
|
||||
else {
|
||||
cout << endl << "Not a valid entry, please try again. ";
|
||||
system("pause");
|
||||
menuChoice = "0";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
31
Project6/Project6.sln
Normal file
31
Project6/Project6.sln
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.6.33801.468
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project6", "Project6.vcxproj", "{8F096234-3F16-4D9F-BB3B-322280A0FBF5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{8F096234-3F16-4D9F-BB3B-322280A0FBF5}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{8F096234-3F16-4D9F-BB3B-322280A0FBF5}.Debug|x64.Build.0 = Debug|x64
|
||||
{8F096234-3F16-4D9F-BB3B-322280A0FBF5}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{8F096234-3F16-4D9F-BB3B-322280A0FBF5}.Debug|x86.Build.0 = Debug|Win32
|
||||
{8F096234-3F16-4D9F-BB3B-322280A0FBF5}.Release|x64.ActiveCfg = Release|x64
|
||||
{8F096234-3F16-4D9F-BB3B-322280A0FBF5}.Release|x64.Build.0 = Release|x64
|
||||
{8F096234-3F16-4D9F-BB3B-322280A0FBF5}.Release|x86.ActiveCfg = Release|Win32
|
||||
{8F096234-3F16-4D9F-BB3B-322280A0FBF5}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {9E0C321B-244B-4BD3-AC84-2D013DFC75CF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
139
Project6/Project6.vcxproj
Normal file
139
Project6/Project6.vcxproj
Normal file
|
@ -0,0 +1,139 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{8f096234-3f16-4d9f-bb3b-322280a0fbf5}</ProjectGuid>
|
||||
<RootNamespace>Project6</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Project6.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="circle.h" />
|
||||
<ClInclude Include="genQueue.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
30
Project6/Project6.vcxproj.filters
Normal file
30
Project6/Project6.vcxproj.filters
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Project6.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="genQueue.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="circle.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
34
Project6/circle.h
Normal file
34
Project6/circle.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#ifndef CIRCLE_HEADER
|
||||
#define CIRCLE_HEADER
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
|
||||
#include <math.h>
|
||||
|
||||
class Circle {
|
||||
private:
|
||||
double radius;
|
||||
|
||||
public:
|
||||
Circle() {
|
||||
radius = 0;
|
||||
}
|
||||
|
||||
Circle(double r) {
|
||||
radius = r;
|
||||
}
|
||||
|
||||
double getRadius() {
|
||||
return radius;
|
||||
}
|
||||
|
||||
void setRadius(double r) {
|
||||
radius = r;
|
||||
}
|
||||
|
||||
double calculateArea() {
|
||||
return M_PI * radius * radius;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
35
Project6/genQueue.h
Normal file
35
Project6/genQueue.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
//********************** genQueue.h *************************
|
||||
// generic queue implemented with doubly linked list
|
||||
|
||||
#ifndef DLL_QUEUE
|
||||
#define DLL_QUEUE
|
||||
|
||||
#include <list>
|
||||
|
||||
template<class T>
|
||||
class Queue {
|
||||
public:
|
||||
Queue() {
|
||||
}
|
||||
void clear() {
|
||||
lst.clear();
|
||||
}
|
||||
bool isEmpty() const {
|
||||
return lst.empty();
|
||||
}
|
||||
T& front() {
|
||||
return lst.front();
|
||||
}
|
||||
T dequeue() {
|
||||
T el = lst.front();
|
||||
lst.pop_front();
|
||||
return el;
|
||||
}
|
||||
void enqueue(const T& el) {
|
||||
lst.push_back(el);
|
||||
}
|
||||
private:
|
||||
list<T> lst;
|
||||
};
|
||||
|
||||
#endif
|
110
Project7/Project7.cpp
Normal file
110
Project7/Project7.cpp
Normal file
|
@ -0,0 +1,110 @@
|
|||
//Corey Williams
|
||||
//COP3530 01Z
|
||||
//Project 7
|
||||
|
||||
/*
|
||||
Write a C / C++ or Java application that creates a Stack data structure.
|
||||
The Stack must be built using a Linked List(i.e., refer to Linked List Implementation, Figure 4.5 pp. 137 - 138).
|
||||
The application also creates a "DisplayStackElement" routine.
|
||||
The application must be menu driven(with an option to terminate the application) and provide the following features.
|
||||
- Allow insertion of a "Circle" object / structure in the Stack data structures.The Circle contains a "radius" data member.
|
||||
The Circle also uses functions / methods "setRadius", "getRadius" and calculateArea(returns a double data type).
|
||||
- Allow display of an element from Stack data structure by Invoking a method / function "DisplayStackElement" (uses the "Pop" method)
|
||||
- Allow for deletion of the Stack
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include <iostream>
|
||||
#include "genListStack.h"
|
||||
#include "circle3.h"
|
||||
#include <string>
|
||||
|
||||
void displayStackElements() {
|
||||
|
||||
}
|
||||
|
||||
void enterStackElements(LLStack<Circle>& s) { //stack is passed in by reference in order to remain persistent between main and function calls
|
||||
system("cls");
|
||||
string r = "0"; //Takes string so that user input can be processed regardless of validity
|
||||
|
||||
//Greeting/instruction text
|
||||
cout << "1. Enter Stack Elements" << endl;
|
||||
cout << "=======================" << endl;
|
||||
cout << "Input a positive number to add a circle with that radius to the stack"
|
||||
<< endl << "or enter q to exit back to the main menu" << endl << endl;
|
||||
|
||||
//Loops until exit condition is input by user
|
||||
while (r != "q") {
|
||||
cout << "Input: ";
|
||||
cin >> r;
|
||||
|
||||
if (r == "q" or r == "Q") { return; }
|
||||
else {
|
||||
try { //try block encapsulates attempt to cast string to double
|
||||
Circle tmp(stod(r)); //instantiates circle with user-input radius
|
||||
s.push(tmp); //adds circle to stack
|
||||
cout << "Circle of radius " << r << " pushed to stack." << endl;
|
||||
}
|
||||
catch (...) { //catches when user input is not able to be used as a numeric input
|
||||
cout << "Not a valid entry, please try again. ";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void displayStackElement(LLStack<Circle>& s) { //pops the top element and prints to screen
|
||||
cout << endl << "Elements:" << endl;
|
||||
if (s.isEmpty()) { cout << endl << "There are no elements to display. "; system("pause"); }
|
||||
string control = "y";
|
||||
while (!s.isEmpty() and control!="n" and control !="N") {
|
||||
Circle tmp = s.pop();
|
||||
cout << endl << "Radius: " << tmp.getRadius();
|
||||
cout << endl << "Area: " << tmp.calculateArea() << endl << endl;
|
||||
|
||||
cout << "Display another element? y/n: ";
|
||||
cin >> control;
|
||||
|
||||
if (s.isEmpty()) { cout << endl << "There are no more elements. "; system("pause"); }
|
||||
}
|
||||
}
|
||||
|
||||
void deleteCurrentStack(LLStack<Circle>& s) { //receives reference to main function's queue and deletes all elements
|
||||
s.clear();
|
||||
cout << endl << endl;
|
||||
cout << "The stack has been cleared. ";
|
||||
system("pause");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
LLStack<Circle> cirStack;
|
||||
string menuChoice = "0";
|
||||
|
||||
//Main Menu - reads string from user and parses for menu selection
|
||||
//Loops until exit condition is input by user
|
||||
while (menuChoice != "4") {
|
||||
menuChoice = "0";
|
||||
system("cls");
|
||||
|
||||
cout << "Main Menu" << endl
|
||||
<< "=========" << endl
|
||||
<< "1. Enter Stack Elements" << endl
|
||||
<< "2. Display Top Element" << endl
|
||||
<< "3. Delete Current Stack" << endl
|
||||
<< "4. Exit Program" << endl
|
||||
<< endl << "Choose an option (1-4): ";
|
||||
cin >> menuChoice;
|
||||
|
||||
if (menuChoice == "1") { enterStackElements(cirStack); }
|
||||
else if (menuChoice == "2") { displayStackElement(cirStack); }
|
||||
else if (menuChoice == "3") { deleteCurrentStack(cirStack); }
|
||||
else if (menuChoice == "4") { return 0; }
|
||||
else {
|
||||
cout << endl << "Not a valid entry, please try again. ";
|
||||
system("pause");
|
||||
menuChoice = "0";
|
||||
}
|
||||
}
|
||||
}
|
31
Project7/Project7.sln
Normal file
31
Project7/Project7.sln
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.6.33801.468
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project7", "Project7.vcxproj", "{38E2962A-AB1A-427A-B095-36C8970694F0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{38E2962A-AB1A-427A-B095-36C8970694F0}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{38E2962A-AB1A-427A-B095-36C8970694F0}.Debug|x64.Build.0 = Debug|x64
|
||||
{38E2962A-AB1A-427A-B095-36C8970694F0}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{38E2962A-AB1A-427A-B095-36C8970694F0}.Debug|x86.Build.0 = Debug|Win32
|
||||
{38E2962A-AB1A-427A-B095-36C8970694F0}.Release|x64.ActiveCfg = Release|x64
|
||||
{38E2962A-AB1A-427A-B095-36C8970694F0}.Release|x64.Build.0 = Release|x64
|
||||
{38E2962A-AB1A-427A-B095-36C8970694F0}.Release|x86.ActiveCfg = Release|Win32
|
||||
{38E2962A-AB1A-427A-B095-36C8970694F0}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {B8C6B9B4-A05D-449C-9C0C-4A77EA20A30B}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
139
Project7/Project7.vcxproj
Normal file
139
Project7/Project7.vcxproj
Normal file
|
@ -0,0 +1,139 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{38e2962a-ab1a-427a-b095-36c8970694f0}</ProjectGuid>
|
||||
<RootNamespace>Project7</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Project7.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="circle3.h" />
|
||||
<ClInclude Include="genListStack.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
30
Project7/Project7.vcxproj.filters
Normal file
30
Project7/Project7.vcxproj.filters
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Project7.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="genListStack.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="circle3.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
34
Project7/circle3.h
Normal file
34
Project7/circle3.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#ifndef CIRCLE_HEADER
|
||||
#define CIRCLE_HEADER
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
|
||||
#include <math.h>
|
||||
|
||||
class Circle {
|
||||
private:
|
||||
double radius;
|
||||
|
||||
public:
|
||||
Circle() {
|
||||
radius = 0;
|
||||
}
|
||||
|
||||
Circle(double r) {
|
||||
radius = r;
|
||||
}
|
||||
|
||||
double getRadius() {
|
||||
return radius;
|
||||
}
|
||||
|
||||
void setRadius(double r) {
|
||||
radius = r;
|
||||
}
|
||||
|
||||
double calculateArea() {
|
||||
return M_PI * radius * radius;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
35
Project7/genListStack.h
Normal file
35
Project7/genListStack.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
//********************** genListStack.h *************************
|
||||
// generic stack defined as a doubly linked list
|
||||
|
||||
#ifndef LL_STACK
|
||||
#define LL_STACK
|
||||
|
||||
#include <list>
|
||||
|
||||
template<class T>
|
||||
class LLStack {
|
||||
public:
|
||||
LLStack() {
|
||||
}
|
||||
void clear() {
|
||||
lst.clear();
|
||||
}
|
||||
bool isEmpty() const {
|
||||
return lst.empty();
|
||||
}
|
||||
T& topEl() {
|
||||
return lst.back();
|
||||
}
|
||||
T pop() {
|
||||
T el = lst.back();
|
||||
lst.pop_back();
|
||||
return el;
|
||||
}
|
||||
void push(const T& el) {
|
||||
lst.push_back(el);
|
||||
}
|
||||
private:
|
||||
list<T> lst;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue