added old projects

This commit is contained in:
Austin Bennett
2026-02-03 08:18:39 -06:00
parent 43acf989bf
commit 2451448b8a
623 changed files with 28117 additions and 0 deletions
BIN
View File
Binary file not shown.
@@ -0,0 +1,290 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 55;
objects = {
/* Begin PBXBuildFile section */
D94331272863F06C00914B9F /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D94331262863F06C00914B9F /* main.cpp */; };
D943312F2863F3E000914B9F /* list.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D943312D2863F3DF00914B9F /* list.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
D94331212863F06C00914B9F /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
D94331232863F06C00914B9F /* BookList */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = BookList; sourceTree = BUILT_PRODUCTS_DIR; };
D94331262863F06C00914B9F /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
D943312D2863F3DF00914B9F /* list.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = list.cpp; sourceTree = "<group>"; };
D9EA3E02286B6984004F363F /* input.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = input.h; sourceTree = "<group>"; };
D9EA3E03286B6B52004F363F /* list.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = list.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
D94331202863F06C00914B9F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
D943311A2863F06C00914B9F = {
isa = PBXGroup;
children = (
D94331252863F06C00914B9F /* BookList */,
D94331242863F06C00914B9F /* Products */,
);
sourceTree = "<group>";
};
D94331242863F06C00914B9F /* Products */ = {
isa = PBXGroup;
children = (
D94331232863F06C00914B9F /* BookList */,
);
name = Products;
sourceTree = "<group>";
};
D94331252863F06C00914B9F /* BookList */ = {
isa = PBXGroup;
children = (
D9EA3E03286B6B52004F363F /* list.h */,
D9EA3E02286B6984004F363F /* input.h */,
D94331262863F06C00914B9F /* main.cpp */,
D943312D2863F3DF00914B9F /* list.cpp */,
);
path = BookList;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
D94331222863F06C00914B9F /* BookList */ = {
isa = PBXNativeTarget;
buildConfigurationList = D943312A2863F06C00914B9F /* Build configuration list for PBXNativeTarget "BookList" */;
buildPhases = (
D943311F2863F06C00914B9F /* Sources */,
D94331202863F06C00914B9F /* Frameworks */,
D94331212863F06C00914B9F /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = BookList;
productName = BookList;
productReference = D94331232863F06C00914B9F /* BookList */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
D943311B2863F06C00914B9F /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastUpgradeCheck = 1340;
TargetAttributes = {
D94331222863F06C00914B9F = {
CreatedOnToolsVersion = 13.4.1;
};
};
};
buildConfigurationList = D943311E2863F06C00914B9F /* Build configuration list for PBXProject "BookList" */;
compatibilityVersion = "Xcode 13.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = D943311A2863F06C00914B9F;
productRefGroup = D94331242863F06C00914B9F /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
D94331222863F06C00914B9F /* BookList */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
D943311F2863F06C00914B9F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D94331272863F06C00914B9F /* main.cpp in Sources */,
D943312F2863F3E000914B9F /* list.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
D94331282863F06C00914B9F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
D94331292863F06C00914B9F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
};
name = Release;
};
D943312B2863F06C00914B9F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = N3GD25M5J3;
ENABLE_HARDENED_RUNTIME = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
D943312C2863F06C00914B9F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = N3GD25M5J3;
ENABLE_HARDENED_RUNTIME = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
D943311E2863F06C00914B9F /* Build configuration list for PBXProject "BookList" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D94331282863F06C00914B9F /* Debug */,
D94331292863F06C00914B9F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
D943312A2863F06C00914B9F /* Build configuration list for PBXNativeTarget "BookList" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D943312B2863F06C00914B9F /* Debug */,
D943312C2863F06C00914B9F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = D943311B2863F06C00914B9F /* Project object */;
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "49A36F6E-754C-42B3-ACFC-B1A11B69FD22"
type = "1"
version = "2.0">
</Bucket>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>BookList.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Binary file not shown.
+28
View File
@@ -0,0 +1,28 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
+46
View File
@@ -0,0 +1,46 @@
#include <iostream>
#include <climits>
#include <string>
template<typename inputType>
inputType ReadValue(std::string prompt)
{
inputType returnValue;
std::cout << prompt;
std::cin >> returnValue;
while (std::cin.fail()) {
std::cout << "Error! Cannot read input.\n";
std::cin.clear();
std::cin.ignore(INT_MAX,'\n');
std::cout << prompt;
std::cin >> returnValue;
}
return returnValue;
}
template<typename inputType>
inputType ReadValue(std::string prompt, inputType minValue)
{
inputType returnValue=0;
returnValue=ReadValue<inputType>(prompt);
while (returnValue < minValue) {
std::cout << "Error! Value must be >= " << minValue << std::endl;
returnValue=ReadValue<inputType>(prompt);
}
return returnValue;
}
template<typename inputType>
inputType ReadValue(std::string prompt, inputType minValue, inputType maxValue)
{
inputType returnValue=0;
returnValue=ReadValue<inputType>(prompt,minValue);
while (returnValue > maxValue) {
std::cout << "Error! Value must be <= " << maxValue << std::endl;
returnValue=ReadValue<inputType>(prompt,minValue);
}
return returnValue;
}
+165
View File
@@ -0,0 +1,165 @@
#include "list.h"
#include "input.h"
#include <exception>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iterator>
void List::Clear()
{
if (size > 0)
{
delete[] data;
size = 0;
data = nullptr;
}
}
std::string List::Display()
{
std::string result;
if (size > 0)
{
std::cout << "List values:\n";
for (std::string *ptr = data; ptr < data + size; ptr++)
{
result = result + *ptr + " ";
}
}
else
{
result = "List is empty.\n";
}
return result;
}
// There must be a function to allow the list size to be increased without losing data that has been previously stored in the list.
void List::Resize(long numValues)
{
try
{
if (numValues < 1 || numValues > MAX_SIZE)
{
throw "Error! Invalid list size specified.";
}
if (size == 0)
{
Clear();
data = new std::string[numValues];
if (data == nullptr)
{
throw "Error! Could not allocate memory for list.";
}
size = numValues;
}
else
{
temp = new std::string[size + numValues];
copy(data, data + size, temp);
Clear();
data = new std::string[size + numValues];
std::string *tempPtr = temp;
for (std::string *ptr=data; ptr<data+size+numValues; ptr++) {
*ptr= *tempPtr;
}
size = numValues + size;
delete[] temp;
}
}
catch (std::exception &e)
{
throw "Error! Could not allocate memory for list.";
}
}
void List::SetValue(std::string value, long pos)
{
if (pos < 0 || pos >= size)
{
throw "Error! Invalid position in list specified.";
}
data[pos] = value;
}
std::string List::GetValue(long pos)
{
if (pos < 0 || pos >= size)
{
throw "Error! Invalid position in list specified.";
}
return data[pos];
}
void List::Remove(std::string value)
{
int index;
for (int i = 0; i < size; i++)
{
if (data[i] == value)
{
index = i;
}
}
for (int i = index; i < size; i++)
data[i] = data[i + 1];
}
void List::Add()
{
try {
long x=ReadValue<long>("Number of values? ");
Resize(x);
if (size == 0) {
for (std::string *ptr=data; ptr<data+size; ptr++) {
*ptr=ReadValue<std::string>("Value? ");
}
} else {
for (std::string *ptr=data; ptr<data+size+x; ptr++) {
*ptr=ReadValue<std::string>("Value? ");
}
}
}
catch (const char* s) {
throw s;
}
}
std::ostream &operator<<(std::ostream &out, List &l)
{
out << l.Display();
return out;
}
List::List()
{
data = nullptr;
size = 0;
}
List::~List()
{
Clear();
}
List::List(const List &x)
{
size = x.size;
data = new std::string[size];
for (long i = 0; i < x.size; i++)
{
data[i] = x.data[i];
}
}
+36
View File
@@ -0,0 +1,36 @@
#ifndef LIST_H
#define LIST_H
#include <iostream>
class List
{
private:
std::string* temp;
public:
std::string* data;
long size;
enum {MAX_SIZE=1000};
void Remove(std::string value);
void Add();
void Resize(long numValues);
void Clear();
void SetValue(std::string value, long pos);
std::string GetValue(long pos);
long GetSize();
void Input(long newSize);
std::string Display();
List();
List(const List& l);
~List();
};
#endif
std::istream& operator>> (std::istream& in, List& l);
std::ostream& operator<< (std::ostream& out, List& l);
+72
View File
@@ -0,0 +1,72 @@
//
// main.cpp
// BookList
//
// Created by Austin Bennett on 6/22/22.
//
/*
Create a C++ program that will keep a list of books. Your program must meet the following criteria:
ø The program will provide the user with a menu to add names to the list, delete a name from the list (searching by title), display the list in it's entirety
√ The list of books will be stored as a dynamically allocated array of strings. The strings can be either STL strings or C style strings
√ The list must be stored in a class
√ There must be an operator overload created for the stream extraction operator that will handle the output of the list
√ You must provide a copy constructor for the class that will allow the programmer to set one class object equal to another
√ There must be a function to allow the list size to be increased without losing data that has been previously stored in the list.
*/
#include <iostream>
#include "list.h"
#include "input.h"
// The program will provide the user with a menu to add names to the list, delete a name from the list (searching by title), display the list in it's entirety
void menu(List books) {
int choice;
bool inProgram = true;
while (inProgram != false){
std::cout << "*******************************\n";
std::cout << " 1 - Add Item.\n";
std::cout << " 2 - Delete Item.\n";
std::cout << " 3 - Display List.\n";
std::cout << " 4 - Exit.\n";
choice = ReadValue<int>("Enter your choice and press return: ");
switch (choice) {
case 1: // Add Item
books.Add();
break;
case 2: // Delete Item
books.Remove(ReadValue<std::string>("Enter Book to Remove: "));
break;
case 3: // Display List
// There must be an operator overload created for the stream extraction operator that will handle the output of the list
std::cout << books;
break;
case 4:
std::cout << "End of Program.\n";
inProgram = false;
break;
default:
std::cout << "Not a Valid Choice. \n";
std::cout << "Choose again.\n";
std::cin >> choice;
break;
}
}
}
int main(int argc, const char * argv[]) {
// The list must be stored in a class
List books;
menu(books);
// You must provide a copy constructor for the class that will allow the programmer to set one class object equal to another
List books2 = List(books);
return 0;
}
BIN
View File
Binary file not shown.
@@ -0,0 +1,300 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 55;
objects = {
/* Begin PBXBuildFile section */
D9284AC62878203F00E2460C /* laborer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D9284AC02878203F00E2460C /* laborer.cpp */; };
D9284AC72878203F00E2460C /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D9284AC12878203F00E2460C /* main.cpp */; };
D9284AC82878203F00E2460C /* manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D9284AC22878203F00E2460C /* manager.cpp */; };
D9284AC92878203F00E2460C /* owner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D9284AC32878203F00E2460C /* owner.cpp */; };
D9284ACA2878203F00E2460C /* person.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D9284AC52878203F00E2460C /* person.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
D9284A8F2877EF2700E2460C /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
D9284A912877EF2700E2460C /* Business */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Business; sourceTree = BUILT_PRODUCTS_DIR; };
D9284AC02878203F00E2460C /* laborer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = laborer.cpp; sourceTree = "<group>"; };
D9284AC12878203F00E2460C /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
D9284AC22878203F00E2460C /* manager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = manager.cpp; sourceTree = "<group>"; };
D9284AC32878203F00E2460C /* owner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = owner.cpp; sourceTree = "<group>"; };
D9284AC42878203F00E2460C /* input.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = input.h; sourceTree = "<group>"; };
D9284AC52878203F00E2460C /* person.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = person.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
D9284A8E2877EF2700E2460C /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
D9284A882877EF2700E2460C = {
isa = PBXGroup;
children = (
D9284A932877EF2700E2460C /* Business */,
D9284A922877EF2700E2460C /* Products */,
);
sourceTree = "<group>";
};
D9284A922877EF2700E2460C /* Products */ = {
isa = PBXGroup;
children = (
D9284A912877EF2700E2460C /* Business */,
);
name = Products;
sourceTree = "<group>";
};
D9284A932877EF2700E2460C /* Business */ = {
isa = PBXGroup;
children = (
D9284AC42878203F00E2460C /* input.h */,
D9284AC02878203F00E2460C /* laborer.cpp */,
D9284AC12878203F00E2460C /* main.cpp */,
D9284AC22878203F00E2460C /* manager.cpp */,
D9284AC32878203F00E2460C /* owner.cpp */,
D9284AC52878203F00E2460C /* person.cpp */,
);
path = Business;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
D9284A902877EF2700E2460C /* Business */ = {
isa = PBXNativeTarget;
buildConfigurationList = D9284A982877EF2700E2460C /* Build configuration list for PBXNativeTarget "Business" */;
buildPhases = (
D9284A8D2877EF2700E2460C /* Sources */,
D9284A8E2877EF2700E2460C /* Frameworks */,
D9284A8F2877EF2700E2460C /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = Business;
productName = Business;
productReference = D9284A912877EF2700E2460C /* Business */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
D9284A892877EF2700E2460C /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastUpgradeCheck = 1340;
TargetAttributes = {
D9284A902877EF2700E2460C = {
CreatedOnToolsVersion = 13.4.1;
};
};
};
buildConfigurationList = D9284A8C2877EF2700E2460C /* Build configuration list for PBXProject "Business" */;
compatibilityVersion = "Xcode 13.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = D9284A882877EF2700E2460C;
productRefGroup = D9284A922877EF2700E2460C /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
D9284A902877EF2700E2460C /* Business */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
D9284A8D2877EF2700E2460C /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D9284AC72878203F00E2460C /* main.cpp in Sources */,
D9284AC92878203F00E2460C /* owner.cpp in Sources */,
D9284AC82878203F00E2460C /* manager.cpp in Sources */,
D9284AC62878203F00E2460C /* laborer.cpp in Sources */,
D9284ACA2878203F00E2460C /* person.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
D9284A962877EF2700E2460C /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
D9284A972877EF2700E2460C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
};
name = Release;
};
D9284A992877EF2700E2460C /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = N3GD25M5J3;
ENABLE_HARDENED_RUNTIME = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
D9284A9A2877EF2700E2460C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = N3GD25M5J3;
ENABLE_HARDENED_RUNTIME = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
D9284A8C2877EF2700E2460C /* Build configuration list for PBXProject "Business" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D9284A962877EF2700E2460C /* Debug */,
D9284A972877EF2700E2460C /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
D9284A982877EF2700E2460C /* Build configuration list for PBXNativeTarget "Business" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D9284A992877EF2700E2460C /* Debug */,
D9284A9A2877EF2700E2460C /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = D9284A892877EF2700E2460C /* Project object */;
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "07C5E0D7-E0E2-49AA-944E-B93BA4DD2C20"
type = "1"
version = "2.0">
</Bucket>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Business.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Binary file not shown.
Binary file not shown.
+8
View File
@@ -0,0 +1,8 @@
{
"files.associations": {
"iosfwd": "cpp",
"typeinfo": "cpp",
"vector": "cpp",
"string": "cpp"
}
}
+28
View File
@@ -0,0 +1,28 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
+49
View File
@@ -0,0 +1,49 @@
/*
* Header file for ReadValue
*/
#include <iostream>
#include <climits>
#include <string>
template<typename inputType>
inputType ReadValue(std::string prompt)
{
inputType returnValue=0;
std::cout << prompt;
std::cin >> returnValue;
while (std::cin.fail()) {
std::cout << "Error! Cannot read input.\n";
std::cin.clear();
std::cin.ignore(INT_MAX,'\n');
std::cout << prompt;
std::cin >> returnValue;
}
return returnValue;
}
template<typename inputType>
inputType ReadValue(std::string prompt, inputType minValue)
{
inputType returnValue=0;
returnValue=ReadValue<inputType>(prompt);
while (returnValue < minValue) {
std::cout << "Error! Value must be >= " << minValue << std::endl;
returnValue=ReadValue<inputType>(prompt);
}
return returnValue;
}
template<typename inputType>
inputType ReadValue(std::string prompt, inputType minValue, inputType maxValue)
{
inputType returnValue=0;
returnValue=ReadValue<inputType>(prompt,minValue);
while (returnValue > maxValue) {
std::cout << "Error! Value must be <= " << maxValue << std::endl;
returnValue=ReadValue<inputType>(prompt,minValue);
}
return returnValue;
}
+40
View File
@@ -0,0 +1,40 @@
#include "person.cpp"
using namespace std;
class Laborer : public Person
{
protected:
string _job;
string _laborerEmployeeID;
string _hourlySalary;
string _hoursWorked;
public:
Laborer(string laborerName, string laborerBirthday, string laborerSSN, string job, string employeeID, string hourlySalary, string hoursWorked) : Person(laborerName, laborerBirthday, laborerSSN)
{
_job = job;
_laborerEmployeeID = employeeID;
_hourlySalary = hourlySalary;
_hoursWorked = hoursWorked;
}
// Accessors
string getJob() { return _job; };
string getEmployeeID() { return _laborerEmployeeID; };
string getHourlySalary() { return _hourlySalary; };
string getHoursWorked() { return _hoursWorked; };
string getType() { return "Laborer"; }
// Mutators
void setJob(string job) { _job = job; };
void setEmployeeID(string employeeID) { _laborerEmployeeID = employeeID; };
void setHourlySalary(string hourlySalary) { _hourlySalary = hourlySalary; };
void setHoursWorked(string hoursWorked) { _hoursWorked = hoursWorked; };
void Display() {
cout << endl;
cout << getType() << ":" << endl;
cout << " " << getName() << " " << getBirthday() << " " << getSSN() << " " << getJob() << " " << getEmployeeID() << " " << getHourlySalary() << " " << getHoursWorked() << endl;
}
};
+233
View File
@@ -0,0 +1,233 @@
//
// main.cpp
// Business
//
// Created by Austin Bennett on 7/7/22.
//
#include <iostream>
#include <vector>
#include "person.cpp"
#include "laborer.cpp"
#include "manager.cpp"
#include "owner.cpp"
using namespace std;
vector<Person *> list;
void DisplayAddMenu()
{
int choice;
do
{
cout << endl
<< " 1 - Add Laborer\n"
<< " 2 - Add Manager\n"
<< " 3 - Add Owner\n"
<< " 4 - Exit.\n"
<< " Enter your choice and press return: ";
cin >> choice;
cout << endl;
if (choice == 1)
{
cout << "Name: ";
string name;
cin.ignore();
getline(cin, name);
cout << "Birthday: ";
string birthday;
getline(cin, birthday);
cout << "SSN: ";
string ssn;
getline(cin, ssn);
cout << "Job: ";
string job;
getline(cin, job);
cout << "Employee ID: ";
string laborerEmployeeID;
getline(cin, laborerEmployeeID);
cout << "Hourly Salary: ";
string hourlySalary;
getline(cin, hourlySalary);
cout << "Hours Worked: ";
string hoursWorked;
getline(cin, hoursWorked);
list.push_back(new Laborer(name, birthday, ssn, job, laborerEmployeeID, hourlySalary, hoursWorked));
}
else if (choice == 2)
{
cout << "Name: ";
string name;
cin.ignore();
getline(cin, name);
cout << "Birthday: ";
string birthday;
getline(cin, birthday);
cout << "SSN: ";
string ssn;
getline(cin, ssn);
cout << "Department: ";
string department;
getline(cin, department);
cout << "Employee ID: ";
string managerEmployeeID;
getline(cin, managerEmployeeID);
cout << "Salary: ";
string salary;
getline(cin, salary);
list.push_back(new Manager(name, birthday, ssn, department, managerEmployeeID, salary));
}
else if (choice == 3)
{
cout << "Name: ";
string name;
cin.ignore();
getline(cin, name);
cout << "Birthday: ";
string birthday;
getline(cin, birthday);
cout << "SSN: ";
string ssn;
getline(cin, ssn);
cout << "Percent Owned: ";
string percentOwned;
getline(cin, percentOwned);
cout << "Owner Since: ";
string ownerSince;
getline(cin, ownerSince);
list.push_back(new Owner(name, birthday, ssn, percentOwned, ownerSince));
}
else if (choice == 4)
{
break;
}
else
{
cout << "Invalid Input\n";
cin.clear();
cin.ignore(10000, '\n');
}
} while (choice != 4);
}
void DisplayListMenu()
{
int choice;
do
{
cout << endl
<< " 1 - View Laborers\n"
<< " 2 - View Managers\n"
<< " 3 - View Owners\n"
<< " 4 - Exit.\n"
<< " Enter your choice and press return: ";
cin >> choice;
cout << endl;
if (choice == 1)
{
for (int i = 0; i < list.size(); i++)
{
Person* person = list[i];
cout << person -> getType();;
string type = list[i]->getType();
if (type == "Laborer")
{
list[i]->Display();
}
}
}
else if (choice == 2)
{
for (int i = 0; i < list.size(); i++)
{
Person *person = list[i];
string type = person->getType();
if (type == "Manager")
{
list[i]->Display();
}
}
}
if (choice == 3)
{
for (int i = 0; i < list.size(); i++)
{
string type = list[i]->getType();
if (type == "Owner")
{
list[i]->Display();
}
}
}
else if (choice == 4)
{
break;
}
else
{
cin.clear();
cin.ignore(10000, '\n');
}
} while (choice != 4);
}
int main()
{
int choice;
do
{
cout << endl
<< " 1 - Add Person\n"
<< " 2 - Display List\n"
<< " 3 - Exit.\n"
<< " Enter your choice and press return: ";
cin >> choice;
cout << endl;
if (choice == 1)
{
DisplayAddMenu();
}
else if (choice == 2)
{
DisplayListMenu();
}
else if (choice == 3)
{
cout << "End of Program.\n";
cin.clear();
cin.ignore(10000, '\n');
}
else
{
cout << "Not a Valid Choice. \nChoose again.\n";
}
} while (choice != 3);
return 0;
}
+36
View File
@@ -0,0 +1,36 @@
#include "person.cpp"
using namespace std;
class Manager : public Person
{
protected:
string _department;
string _managerEmployeeID;
string _salary;
public:
Manager(string managerName, string managerBirthday, string managerSSN, string department, string employeeID, string salary) : Person(managerName, managerBirthday, managerSSN)
{
_department = department;
_managerEmployeeID = employeeID;
_salary = salary;
}
// Accessors
string getDepartment() { return _department; };
string getEmployeeID() { return _managerEmployeeID; };
string getSalary() { return _salary; };
string getType() { return "Manager"; };
// Mutators
void setDepartment(string department) { _department = department; };
void setEmployeeID(string employeeID) { _managerEmployeeID = employeeID; };
void setSalary(string salary) { _salary = salary; };
void Display() {
cout << endl;
cout << getType() << ":" << endl;
cout << " " << getName() << " " << getBirthday() << " " << getSSN() << " " << getDepartment() << " " << getEmployeeID() << " " << getSalary() << endl;
}
};
+32
View File
@@ -0,0 +1,32 @@
#include "person.cpp"
using namespace std;
class Owner : public Person
{
protected:
string _percentOwned;
string _ownerSince;
public:
Owner(string ownerName, string ownerBirthday, string ownerSSN, string percentOwned, string ownerSince) : Person(ownerName, ownerBirthday, ownerSSN)
{
_percentOwned = percentOwned;
_ownerSince = ownerSince;
}
// Accessors
string getPercentOwned() { return _percentOwned; };
string getOwnerSince() { return _ownerSince; };
string getType() { return "Owner"; };
// Mutators
void setPercentOwned(string percentOwned) { _percentOwned = percentOwned; };
void setOwnerSince(string ownerSince) { _ownerSince = ownerSince; };
void Display() {
cout << endl;
cout << getType() << ":" << endl;
cout << " " << getName() << " " << getBirthday() << " " << getSSN() << " " << getPercentOwned() << " " << getOwnerSince()<< endl;
}
};
+36
View File
@@ -0,0 +1,36 @@
#include <string>
#include <iostream>
#pragma once
using namespace std;
class Person
{
protected:
string _name;
string _birthday;
string _ssn;
public:
Person(string name, string birthday, string ssn)
{
_name = name;
_birthday = birthday;
_ssn = ssn;
}
// Accessors
string getName() { return _name; };
string getBirthday() { return _birthday; };
string getSSN() { return _ssn; };
// Mutators
void setName(string name) { _name = name; }
void setBirthday(string birthday) { _birthday = birthday; };
void setSSN(string ssn) { _ssn = ssn; };
virtual void Display() = 0;
virtual string getType();
};
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
1200.43 .08 60
@@ -0,0 +1,107 @@
//
// main.cpp
// CompoundingInterest
//
// Created by Austin Bennett on 6/19/22.
//
/*
Write a program that read the starting balance, interest rate and number of months from a file.
Example:
1200.43 .08 60
(Balance of $1200.43, 8 percent interest rate, 60 months)
your program will print out a table showing month number and current balance (assume it is compounded monthly) for the number of specified months. Your program should prompt the user for the name of the output file. Use the formatting function you created previously to format the amount. Please note that the output of the program must show balance each month - not just the total at the end.
Example:
0 1,200.43
1 1,208.44
2 1,216.54
etc.
*/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
string Format(double input) {
char result[] {};
// resultIndex will handle what goes where in our output
int resultIndex = 0;
//Making the input nice to work with
std::string inputString = to_string(input);
char num[inputString.length() + 1];
strcpy(num, inputString.c_str());
// characteristic is all the numbers on the right of the decimal point
char* characteristic = strtok(num, ".");
int characteristicLen = strlen(characteristic);
int characteristicIndex {0};
// this adds the commas
for (int i = characteristicLen - 1 ; i >= 0; i--) {
bool isComma = ((i + 1) % 3 == 0);
if (isComma) {
result[resultIndex] = ',';
resultIndex++;
result[resultIndex] = characteristic[characteristicIndex];
characteristicIndex++;
resultIndex++;
} else {
result[resultIndex] = characteristic[characteristicIndex];
characteristicIndex++;
resultIndex++;
}
}
//adds the decimal
result[resultIndex] = '.';
resultIndex++;
// creates the mantissa
characteristic = strtok(NULL, ".");
//adds the decimals
for (int i = 0; i <= 1; i++) {
result[resultIndex] = characteristic[i]; // the mantissa's value at index i
resultIndex++;
characteristicIndex++;
}
//builds out the result
string s = "";
for (size_t i = 0; i < resultIndex; i++) {
s = s + result[i];
}
return s;
}
int main()
{
// Get intial values
float newBalance, interestRate, months, oldBalance;
fstream input("/Users/austin/Documents/School/Summer 2022/CSC 122/CompoundingInterest/CompoundingInterest/input.txt", ios_base::in);
input >> oldBalance >> interestRate >> months;
// Build the output file
string fileName;
cout << "Enter File Name (No extension): ";
cin >> fileName;
ofstream output;
output.open ("/Users/austin/Documents/School/Summer 2022/CSC 122/CompoundingInterest/CompoundingInterest/" + fileName + ".txt");
//Assuming the first month counts as one of the input months
output << "0 " << Format(oldBalance) << endl;
for (int i = 1; i < months; i++) {
newBalance = ( 1 + interestRate / 12 ) * oldBalance;
output << i << " " << Format(newBalance) << endl;
oldBalance = newBalance;
}
}
@@ -0,0 +1,60 @@
0 1,200.43
1 1,208.43
2 1,216.48
3 1,224.59
4 1,232.76
5 1,240.98
6 1,249.25
7 1,257.58
8 1,265.96
9 1,274.40
10 1,282.90
11 1,291.45
12 1,300.06
13 1,308.73
14 1,317.45
15 1,326.24
16 1,335.08
17 1,343.98
18 1,352.94
19 1,361.96
20 1,371.04
21 1,380.18
22 1,389.38
23 1,398.64
24 1,407.96
25 1,417.35
26 1,426.80
27 1,436.31
28 1,445.89
29 1,455.53
30 1,465.23
31 1,475.00
32 1,484.83
33 1,494.73
34 1,504.70
35 1,514.73
36 1,524.83
37 1,534.99
38 1,545.22
39 1,555.53
40 1,565.90
41 1,576.34
42 1,586.84
43 1,597.42
44 1,608.07
45 1,618.79
46 1,629.59
47 1,640.45
48 1,651.39
49 1,662.39
50 1,673.48
51 1,684.63
52 1,695.86
53 1,707.17
54 1,718.55
55 1,730.01
56 1,741.54
57 1,753.15
58 1,764.84
59 1,776.61
@@ -0,0 +1,284 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 55;
objects = {
/* Begin PBXBuildFile section */
D9A8F12628602FE00025DE2F /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D9A8F12528602FE00025DE2F /* main.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
D9A8F12028602FE00025DE2F /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
D9A8F12228602FE00025DE2F /* CompoundingInterest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = CompoundingInterest; sourceTree = BUILT_PRODUCTS_DIR; };
D9A8F12528602FE00025DE2F /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
D9A8F12C2860CA360025DE2F /* input.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = input.txt; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
D9A8F11F28602FE00025DE2F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
D9A8F11928602FDF0025DE2F = {
isa = PBXGroup;
children = (
D9A8F12428602FE00025DE2F /* CompoundingInterest */,
D9A8F12328602FE00025DE2F /* Products */,
);
sourceTree = "<group>";
};
D9A8F12328602FE00025DE2F /* Products */ = {
isa = PBXGroup;
children = (
D9A8F12228602FE00025DE2F /* CompoundingInterest */,
);
name = Products;
sourceTree = "<group>";
};
D9A8F12428602FE00025DE2F /* CompoundingInterest */ = {
isa = PBXGroup;
children = (
D9A8F12528602FE00025DE2F /* main.cpp */,
D9A8F12C2860CA360025DE2F /* input.txt */,
);
path = CompoundingInterest;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
D9A8F12128602FE00025DE2F /* CompoundingInterest */ = {
isa = PBXNativeTarget;
buildConfigurationList = D9A8F12928602FE00025DE2F /* Build configuration list for PBXNativeTarget "CompoundingInterest" */;
buildPhases = (
D9A8F11E28602FE00025DE2F /* Sources */,
D9A8F11F28602FE00025DE2F /* Frameworks */,
D9A8F12028602FE00025DE2F /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = CompoundingInterest;
productName = CompoundingInterest;
productReference = D9A8F12228602FE00025DE2F /* CompoundingInterest */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
D9A8F11A28602FDF0025DE2F /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastUpgradeCheck = 1340;
TargetAttributes = {
D9A8F12128602FE00025DE2F = {
CreatedOnToolsVersion = 13.4.1;
};
};
};
buildConfigurationList = D9A8F11D28602FDF0025DE2F /* Build configuration list for PBXProject "CompoundingInterest" */;
compatibilityVersion = "Xcode 13.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = D9A8F11928602FDF0025DE2F;
productRefGroup = D9A8F12328602FE00025DE2F /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
D9A8F12128602FE00025DE2F /* CompoundingInterest */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
D9A8F11E28602FE00025DE2F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D9A8F12628602FE00025DE2F /* main.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
D9A8F12728602FE00025DE2F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
D9A8F12828602FE00025DE2F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
};
name = Release;
};
D9A8F12A28602FE00025DE2F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = N3GD25M5J3;
ENABLE_HARDENED_RUNTIME = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
D9A8F12B28602FE00025DE2F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = N3GD25M5J3;
ENABLE_HARDENED_RUNTIME = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
D9A8F11D28602FDF0025DE2F /* Build configuration list for PBXProject "CompoundingInterest" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D9A8F12728602FE00025DE2F /* Debug */,
D9A8F12828602FE00025DE2F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
D9A8F12928602FE00025DE2F /* Build configuration list for PBXNativeTarget "CompoundingInterest" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D9A8F12A28602FE00025DE2F /* Debug */,
D9A8F12B28602FE00025DE2F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = D9A8F11A28602FDF0025DE2F /* Project object */;
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "6562050E-6DA9-4961-9E62-10E7BE6E4F66"
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "112F048C-AD5D-4364-8B24-A19B9AC678CA"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "CompoundingInterest/input.h"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "15"
endingLineNumber = "15"
landmarkName = "ReadValue(prompt)"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>CompoundingInterest.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
1200.43 .08 60
@@ -0,0 +1,107 @@
//
// main.cpp
// CompoundingInterest
//
// Created by Austin Bennett on 6/19/22.
//
/*
Write a program that read the starting balance, interest rate and number of months from a file.
Example:
1200.43 .08 60
(Balance of $1200.43, 8 percent interest rate, 60 months)
your program will print out a table showing month number and current balance (assume it is compounded monthly) for the number of specified months. Your program should prompt the user for the name of the output file. Use the formatting function you created previously to format the amount. Please note that the output of the program must show balance each month - not just the total at the end.
Example:
0 1,200.43
1 1,208.44
2 1,216.54
etc.
*/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
string Format(double input) {
char result[] {};
// resultIndex will handle what goes where in our output
int resultIndex = 0;
//Making the input nice to work with
std::string inputString = to_string(input);
char num[inputString.length() + 1];
strcpy(num, inputString.c_str());
// characteristic is all the numbers on the right of the decimal point
char* characteristic = strtok(num, ".");
int characteristicLen = strlen(characteristic);
int characteristicIndex {0};
// this adds the commas
for (int i = characteristicLen - 1 ; i >= 0; i--) {
bool isComma = ((i + 1) % 3 == 0);
if (isComma) {
result[resultIndex] = ',';
resultIndex++;
result[resultIndex] = characteristic[characteristicIndex];
characteristicIndex++;
resultIndex++;
} else {
result[resultIndex] = characteristic[characteristicIndex];
characteristicIndex++;
resultIndex++;
}
}
//adds the decimal
result[resultIndex] = '.';
resultIndex++;
// creates the mantissa
characteristic = strtok(NULL, ".");
//adds the decimals
for (int i = 0; i <= 1; i++) {
result[resultIndex] = characteristic[i]; // the mantissa's value at index i
resultIndex++;
characteristicIndex++;
}
//builds out the result
string s = "";
for (size_t i = 0; i < resultIndex; i++) {
s = s + result[i];
}
return s;
}
int main()
{
// Get intial values
float newBalance, interestRate, months, oldBalance;
fstream input("/Users/austin/Documents/School/Summer 2022/CSC 122/CompoundingInterest/CompoundingInterest/input.txt", ios_base::in);
input >> oldBalance >> interestRate >> months;
// Build the output file
string fileName;
cout << "Enter File Name (No extension): ";
cin >> fileName;
ofstream output;
output.open ("/Users/austin/Documents/School/Summer 2022/CSC 122/CompoundingInterest/CompoundingInterest/" + fileName + ".txt");
//Assuming the first month counts as one of the input months
output << "0 " << Format(oldBalance) << endl;
for (int i = 1; i < months; i++) {
newBalance = ( 1 + interestRate / 12 ) * oldBalance;
output << i << " " << Format(newBalance) << endl;
oldBalance = newBalance;
}
}
@@ -0,0 +1,60 @@
0 1,200.43
1 1,208.43
2 1,216.48
3 1,224.59
4 1,232.76
5 1,240.98
6 1,249.25
7 1,257.58
8 1,265.96
9 1,274.40
10 1,282.90
11 1,291.45
12 1,300.06
13 1,308.73
14 1,317.45
15 1,326.24
16 1,335.08
17 1,343.98
18 1,352.94
19 1,361.96
20 1,371.04
21 1,380.18
22 1,389.38
23 1,398.64
24 1,407.96
25 1,417.35
26 1,426.80
27 1,436.31
28 1,445.89
29 1,455.53
30 1,465.23
31 1,475.00
32 1,484.83
33 1,494.73
34 1,504.70
35 1,514.73
36 1,524.83
37 1,534.99
38 1,545.22
39 1,555.53
40 1,565.90
41 1,576.34
42 1,586.84
43 1,597.42
44 1,608.07
45 1,618.79
46 1,629.59
47 1,640.45
48 1,651.39
49 1,662.39
50 1,673.48
51 1,684.63
52 1,695.86
53 1,707.17
54 1,718.55
55 1,730.01
56 1,741.54
57 1,753.15
58 1,764.84
59 1,776.61
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,296 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 56;
objects = {
/* Begin PBXBuildFile section */
D94DBF2B2885BA67008CA966 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D94DBF2A2885BA67008CA966 /* main.cpp */; };
D9600E3A28863970002D0806 /* node.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D9600E3828863970002D0806 /* node.cpp */; };
D9600E3D288639ED002D0806 /* doublylinkedlist.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D9600E3B288639ED002D0806 /* doublylinkedlist.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
D94DBF252885BA67008CA966 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
D94DBF272885BA67008CA966 /* DoublyLinkedList */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DoublyLinkedList; sourceTree = BUILT_PRODUCTS_DIR; };
D94DBF2A2885BA67008CA966 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
D9600E3828863970002D0806 /* node.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = node.cpp; sourceTree = "<group>"; };
D9600E3928863970002D0806 /* node.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = node.hpp; sourceTree = "<group>"; };
D9600E3B288639ED002D0806 /* doublylinkedlist.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = doublylinkedlist.cpp; sourceTree = "<group>"; };
D9600E3C288639ED002D0806 /* doublylinkedlist.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = doublylinkedlist.hpp; sourceTree = "<group>"; };
D9600E3E28864BBD002D0806 /* input.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = input.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
D94DBF242885BA67008CA966 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
D94DBF1E2885BA67008CA966 = {
isa = PBXGroup;
children = (
D94DBF292885BA67008CA966 /* DoublyLinkedList */,
D94DBF282885BA67008CA966 /* Products */,
);
sourceTree = "<group>";
};
D94DBF282885BA67008CA966 /* Products */ = {
isa = PBXGroup;
children = (
D94DBF272885BA67008CA966 /* DoublyLinkedList */,
);
name = Products;
sourceTree = "<group>";
};
D94DBF292885BA67008CA966 /* DoublyLinkedList */ = {
isa = PBXGroup;
children = (
D9600E3E28864BBD002D0806 /* input.h */,
D94DBF2A2885BA67008CA966 /* main.cpp */,
D9600E3828863970002D0806 /* node.cpp */,
D9600E3928863970002D0806 /* node.hpp */,
D9600E3B288639ED002D0806 /* doublylinkedlist.cpp */,
D9600E3C288639ED002D0806 /* doublylinkedlist.hpp */,
);
path = DoublyLinkedList;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
D94DBF262885BA67008CA966 /* DoublyLinkedList */ = {
isa = PBXNativeTarget;
buildConfigurationList = D94DBF2E2885BA67008CA966 /* Build configuration list for PBXNativeTarget "DoublyLinkedList" */;
buildPhases = (
D94DBF232885BA67008CA966 /* Sources */,
D94DBF242885BA67008CA966 /* Frameworks */,
D94DBF252885BA67008CA966 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = DoublyLinkedList;
productName = DoublyLinkedList;
productReference = D94DBF272885BA67008CA966 /* DoublyLinkedList */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
D94DBF1F2885BA67008CA966 /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastUpgradeCheck = 1400;
TargetAttributes = {
D94DBF262885BA67008CA966 = {
CreatedOnToolsVersion = 14.0;
};
};
};
buildConfigurationList = D94DBF222885BA67008CA966 /* Build configuration list for PBXProject "DoublyLinkedList" */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = D94DBF1E2885BA67008CA966;
productRefGroup = D94DBF282885BA67008CA966 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
D94DBF262885BA67008CA966 /* DoublyLinkedList */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
D94DBF232885BA67008CA966 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D94DBF2B2885BA67008CA966 /* main.cpp in Sources */,
D9600E3A28863970002D0806 /* node.cpp in Sources */,
D9600E3D288639ED002D0806 /* doublylinkedlist.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
D94DBF2C2885BA67008CA966 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
D94DBF2D2885BA67008CA966 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
};
name = Release;
};
D94DBF2F2885BA67008CA966 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = N3GD25M5J3;
ENABLE_HARDENED_RUNTIME = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
D94DBF302885BA67008CA966 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = N3GD25M5J3;
ENABLE_HARDENED_RUNTIME = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
D94DBF222885BA67008CA966 /* Build configuration list for PBXProject "DoublyLinkedList" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D94DBF2C2885BA67008CA966 /* Debug */,
D94DBF2D2885BA67008CA966 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
D94DBF2E2885BA67008CA966 /* Build configuration list for PBXNativeTarget "DoublyLinkedList" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D94DBF2F2885BA67008CA966 /* Debug */,
D94DBF302885BA67008CA966 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = D94DBF1F2885BA67008CA966 /* Project object */;
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "BE8CEB0C-9E10-40CF-99EA-D35BAD672829"
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "FDA67FEE-0973-43F2-97CC-329B476FDABB"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "DoublyLinkedList/doublylinkedlist.cpp"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "53"
endingLineNumber = "53"
landmarkName = "DoublyLinkedList::Remove(index)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "EC240E5E-A1E1-489F-8226-2E8EC813A75B"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "DoublyLinkedList/doublylinkedlist.cpp"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "56"
endingLineNumber = "56"
landmarkName = "DoublyLinkedList::Remove(index)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "C2F43595-2D23-4C6B-89BA-AA9518B7082B"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "DoublyLinkedList/doublylinkedlist.cpp"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "54"
endingLineNumber = "54"
landmarkName = "DoublyLinkedList::Remove(index)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>DoublyLinkedList.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 507 KiB

@@ -0,0 +1,98 @@
//
// doublylinkedlist.cpp
// DoublyLinkedList
//
// Created by Austin Bennett on 7/18/22.
//
/*
Constructor
Destructor
Insert function
Remove function
Accessor function
Mutator function
*/
#include <iostream>
#include "doublylinkedlist.hpp"
using namespace::std;
DoublyLinkedList::DoublyLinkedList() {
front = NULL;
back = NULL;
}
void DoublyLinkedList::Insert(double data) {
Node* newNode = new Node(data);
bool isEmpty = (front == NULL);
if (isEmpty) {
front = newNode;
back = newNode;
newNode -> prev = NULL;
newNode -> next = NULL;
} else {
back -> next = newNode;
newNode -> prev = back;
newNode -> next = NULL;
back = newNode;
}
}
void DoublyLinkedList::Remove(int index) {
Node* temp = front;
int count = 0;
for (int i = 0; temp != NULL && i < index; i++) {
temp = temp -> next;
}
if (temp == front) {
temp -> next = front;
front -> prev = NULL;
} else if (temp == back) {
temp -> prev = back;
back -> next = NULL;
} else {
Node* a = temp -> prev;
Node* b = temp -> next;
b -> prev = a;
a -> next = b;
}
free(temp);
return;
}
void DoublyLinkedList::DisplayFB() {
Node* temp = front;
while (temp != NULL) {
cout << temp -> data << " -> ";
temp = temp -> next;
}
cout << "NULL" << endl;
}
void DoublyLinkedList::DisplayBF() {
Node* temp = back;
while (temp != NULL) {
cout << temp -> data << " -> ";
temp = temp -> prev;
}
cout << "NULL" << endl;
}
void DoublyLinkedList::Mutate(int index, double value) {
Node* temp = front;
for (int i = 0; temp != NULL && i < index; i++) {
temp = temp->next;
}
temp -> data = value;
}
@@ -0,0 +1,37 @@
//
// doublylinkedlist.hpp
// DoublyLinkedList
//
// Created by Austin Bennett on 7/18/22.
//
/*
Constructor
Destructor
Insert function
Remove function
Accessor function
Mutator function
*/
#ifndef doublylinkedlist_hpp
#define doublylinkedlist_hpp
#include <stdio.h>
#include "node.hpp"
class DoublyLinkedList {
private:
Node* front;
Node* back;
public:
DoublyLinkedList();
//~DoublyLinkedList();
void Insert(double data);
void Remove(int index);
void DisplayFB();
void DisplayBF();
void Mutate(int index, double value);
};
#endif /* doublylinkedlist_hpp */
@@ -0,0 +1,49 @@
/*
* Header file for ReadValue
*/
#include <iostream>
#include <climits>
#include <string>
template<typename inputType>
inputType ReadValue(std::string prompt)
{
inputType returnValue=0;
std::cout << prompt;
std::cin >> returnValue;
while (std::cin.fail()) {
std::cout << "Error! Cannot read input.\n";
std::cin.clear();
std::cin.ignore(INT_MAX,'\n');
std::cout << prompt;
std::cin >> returnValue;
}
return returnValue;
}
template<typename inputType>
inputType ReadValue(std::string prompt, inputType minValue)
{
inputType returnValue=0;
returnValue=ReadValue<inputType>(prompt);
while (returnValue < minValue) {
std::cout << "Error! Value must be >= " << minValue << std::endl;
returnValue=ReadValue<inputType>(prompt);
}
return returnValue;
}
template<typename inputType>
inputType ReadValue(std::string prompt, inputType minValue, inputType maxValue)
{
inputType returnValue=0;
returnValue=ReadValue<inputType>(prompt,minValue);
while (returnValue > maxValue) {
std::cout << "Error! Value must be <= " << maxValue << std::endl;
returnValue=ReadValue<inputType>(prompt,minValue);
}
return returnValue;
}
@@ -0,0 +1,44 @@
#include <iostream>
#include "doublylinkedlist.hpp"
#include "input.h"
using namespace std;
int main()
{
DoublyLinkedList dll = DoublyLinkedList();
cout << "1. Add Value" << endl;
cout << "2. Delete Value" << endl;
cout << "3. Display List (forward)" << endl;
cout << "4. Display List (backward)" << endl;
cout << "5. Quit" << endl;
int choice = ReadValue<int>("Enter Your Choice: ");
do {
if (choice == 1) {
dll.Insert(ReadValue<double>("Enter Your Data: "));
} else if (choice == 2) {
dll.Remove(ReadValue<int>("Enter The Index: "));
} else if (choice == 3) {
dll.DisplayFB();
} else if (choice == 4) {
dll.DisplayBF();
} else if (choice == 5) {
break;
} else {
cout << "Try Again" << endl;
}
// cout << "1. Add Value" << endl;
// cout << "2. Delete Value" << endl;
// cout << "3. Display List (forward)" << endl;
// cout << "4. Display List (backward)" << endl;
// cout << "5. Quit" << endl;
choice = ReadValue<int>("Enter Your Choice: ");
} while (choice != 5);
return 0;
}
@@ -0,0 +1,16 @@
//
// node.cpp
// DoublyLinkedList
//
// Created by Austin Bennett on 7/18/22.
//
#include "node.hpp"
Node::Node(double value) {
data = value;
}
Node::~Node() {
delete this;
}
@@ -0,0 +1,22 @@
//
// node.hpp
// DoublyLinkedList
//
// Created by Austin Bennett on 7/18/22.
//
#ifndef node_hpp
#define node_hpp
#include <stdio.h>
struct Node {
public:
double data;
struct Node *prev;
struct Node *next;
Node(double value);
~Node();
};
#endif /* node_hpp */
BIN
View File
Binary file not shown.
+8
View File
@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
+2
View File
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ListClass.iml" filepath="$PROJECT_DIR$/.idea/ListClass.iml" />
</modules>
</component>
</project>
@@ -0,0 +1,290 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 55;
objects = {
/* Begin PBXBuildFile section */
D9A8F10D28600B5A0025DE2F /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D9A8F10C28600B5A0025DE2F /* main.cpp */; };
D9A8F11628600B670025DE2F /* list.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D9A8F11528600B670025DE2F /* list.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
D9A8F10728600B5A0025DE2F /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
D9A8F10928600B5A0025DE2F /* ListClass */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ListClass; sourceTree = BUILT_PRODUCTS_DIR; };
D9A8F10C28600B5A0025DE2F /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
D9A8F11328600B670025DE2F /* list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = list.h; sourceTree = "<group>"; };
D9A8F11428600B670025DE2F /* input.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = input.h; sourceTree = "<group>"; };
D9A8F11528600B670025DE2F /* list.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = list.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
D9A8F10628600B5A0025DE2F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
D9A8F10028600B5A0025DE2F = {
isa = PBXGroup;
children = (
D9A8F10B28600B5A0025DE2F /* ListClass */,
D9A8F10A28600B5A0025DE2F /* Products */,
);
sourceTree = "<group>";
};
D9A8F10A28600B5A0025DE2F /* Products */ = {
isa = PBXGroup;
children = (
D9A8F10928600B5A0025DE2F /* ListClass */,
);
name = Products;
sourceTree = "<group>";
};
D9A8F10B28600B5A0025DE2F /* ListClass */ = {
isa = PBXGroup;
children = (
D9A8F10C28600B5A0025DE2F /* main.cpp */,
D9A8F11428600B670025DE2F /* input.h */,
D9A8F11528600B670025DE2F /* list.cpp */,
D9A8F11328600B670025DE2F /* list.h */,
);
path = ListClass;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
D9A8F10828600B5A0025DE2F /* ListClass */ = {
isa = PBXNativeTarget;
buildConfigurationList = D9A8F11028600B5A0025DE2F /* Build configuration list for PBXNativeTarget "ListClass" */;
buildPhases = (
D9A8F10528600B5A0025DE2F /* Sources */,
D9A8F10628600B5A0025DE2F /* Frameworks */,
D9A8F10728600B5A0025DE2F /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = ListClass;
productName = ListClass;
productReference = D9A8F10928600B5A0025DE2F /* ListClass */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
D9A8F10128600B5A0025DE2F /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastUpgradeCheck = 1340;
TargetAttributes = {
D9A8F10828600B5A0025DE2F = {
CreatedOnToolsVersion = 13.4.1;
};
};
};
buildConfigurationList = D9A8F10428600B5A0025DE2F /* Build configuration list for PBXProject "ListClass" */;
compatibilityVersion = "Xcode 13.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = D9A8F10028600B5A0025DE2F;
productRefGroup = D9A8F10A28600B5A0025DE2F /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
D9A8F10828600B5A0025DE2F /* ListClass */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
D9A8F10528600B5A0025DE2F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D9A8F10D28600B5A0025DE2F /* main.cpp in Sources */,
D9A8F11628600B670025DE2F /* list.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
D9A8F10E28600B5A0025DE2F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
D9A8F10F28600B5A0025DE2F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
};
name = Release;
};
D9A8F11128600B5A0025DE2F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = N3GD25M5J3;
ENABLE_HARDENED_RUNTIME = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
D9A8F11228600B5A0025DE2F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = N3GD25M5J3;
ENABLE_HARDENED_RUNTIME = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
D9A8F10428600B5A0025DE2F /* Build configuration list for PBXProject "ListClass" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D9A8F10E28600B5A0025DE2F /* Debug */,
D9A8F10F28600B5A0025DE2F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
D9A8F11028600B5A0025DE2F /* Build configuration list for PBXNativeTarget "ListClass" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D9A8F11128600B5A0025DE2F /* Debug */,
D9A8F11228600B5A0025DE2F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = D9A8F10128600B5A0025DE2F /* Project object */;
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "0A31909E-2B3E-452C-8694-B366F07AEA17"
type = "1"
version = "2.0">
</Bucket>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>ListClass.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Binary file not shown.
Binary file not shown.
+46
View File
@@ -0,0 +1,46 @@
#include <iostream>
#include <climits>
#include <string>
template <typename inputType>
inputType ReadValue(std::string prompt)
{
inputType returnValue = 0;
std::cout << prompt;
std::cin >> returnValue;
while (std::cin.fail())
{
std::cout << "Error! Cannot read input.\n";
std::cin.clear();
std::cin.ignore(INT_MAX, '\n');
std::cout << prompt;
std::cin >> returnValue;
}
return returnValue;
}
template <typename inputType>
inputType ReadValue(std::string prompt, inputType minValue)
{
inputType returnValue = 0;
returnValue = ReadValue<inputType>(prompt);
while (returnValue < minValue)
{
std::cout << "Error! Value must be >= " << minValue << std::endl;
returnValue = ReadValue<inputType>(prompt);
}
return returnValue;
}
template <typename inputType>
inputType ReadValue(std::string prompt, inputType minValue, inputType maxValue)
{
inputType returnValue = 0;
returnValue = ReadValue<inputType>(prompt, minValue);
while (returnValue > maxValue)
{
std::cout << "Error! Value must be <= " << maxValue << std::endl;
returnValue = ReadValue<inputType>(prompt, minValue);
}
return returnValue;
}
+185
View File
@@ -0,0 +1,185 @@
#include "list.h"
#include "input.h"
#include <exception>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iterator>
using namespace std;
void List::Clear()
{
if (size > 0)
{
delete[] data;
size = 0;
data = nullptr;
}
}
void List::Resize(long numValues)
{
try
{
if (numValues < 1 || numValues > MAX_SIZE)
{
throw "Error! Invalid list size specified.";
}
if (size == 0) {
Clear();
data = new double[numValues];
if (data == nullptr)
{
throw "Error! Could not allocate memory for list.";
}
size = numValues;
} else {
temp = new double[size];
long tempSize = size;
copy(data, data+numValues, temp);
Clear();
data = new double[numValues];
size = numValues;
for (int i = 0; i < tempSize; i++){
data[i] = temp[i];
}
delete[] temp;
}
}
catch (std::exception &e)
{
throw "Error! Could not allocate memory for list.";
}
}
void List::SetValue(double value, long pos)
{
if (pos < 0 || pos >= size)
{
throw "Error! Invalid position in list specified.";
}
data[pos] = value;
}
double List::GetValue(long pos)
{
if (pos < 0 || pos >= size)
{
throw "Error! Invalid position in list specified.";
}
return data[pos];
}
//Bubble Sort beacuse I'm too lazy to add Quick Sort
void List::BubbleSort() {
double* ptr = data;
int i, j, t;
for (i = 0; i < size; i++) {
for (j = i + 1; j < size; j++) {
if (*(ptr + j) < *(ptr + i)) {
t = *(ptr + i);
*(ptr + i) = *(ptr + j);
*(ptr + j) = t;
}
}
}
}
double List::Median() {
// Cases: Odd or Even
// Sort -> check odd or even -> find the middle of list
bool isEven = (size % 2 == 0);
int midIndex = ceil(size/2);
double median = NULL;
double* ptr = data;
// Sort
BubbleSort();
// Check if Odd or Even
if (isEven) {
// find the middle of the list
median = (ptr[midIndex] + ptr[midIndex - 1]) / 2;
} else {
// find the middle of the list
median = (double)ptr[size / 2];
}
return median;
}
double List::Average() {
double total = NULL;
for (double *ptr = data; ptr < data + size; ptr++)
{
total += *ptr;
}
return total / size;
}
void List::Input()
{
try
{
if (size == 0)
{
long x = ReadValue<long>("Number of values? ");
Resize(x);
}
for (double *ptr = data; ptr < data + size; ptr++)
{
*ptr = ReadValue<double>("Value? ");
}
}
catch (const char *s)
{
throw s;
}
}
void List::Display()
{
if (size > 0)
{
std::cout << "List values:\n";
for (double *ptr = data; ptr < data + size; ptr++)
{
std::cout << *ptr << " ";
}
std::cout << std::endl;
}
else
{
std::cout << "List is empty.\n";
}
}
long List::GetSize() {
return size;
}
List::List()
{
data = nullptr;
size = 0;
}
List::~List()
{
Clear();
}
+31
View File
@@ -0,0 +1,31 @@
#ifndef LIST_H
#define LIST_H
class List
{
private:
double *data;
long size;
double *temp;
public:
enum
{
MAX_SIZE = 1000
};
void Resize(long numValues);
void Clear();
void BubbleSort();
double Median();
double Average();
void SetValue(double value, long pos);
double GetValue(long pos);
long GetSize();
void Input();
void Display();
List();
~List();
};
#endif
+59
View File
@@ -0,0 +1,59 @@
/*
Add the following functionality to the list class to do the following:
Add a function to sort the data, calculate the average and determine the median.
Also modify the Resize() function to do the following:
Allow the function to resize the modify the size of the array. If the new size is larger than the old size, the data values in the array should be copied into the new.
-> If the new array is smaller than the original, it should copy only as many values as the new array will hold.
Use this class to write a program to allow the user to enter a list of values, then display the list, sort and redisplay the list and display the average and median.
Also resize the list to a larger size, display then resize to a smaller size and redisplay to demonstrate the resizing functionality.
*/
#include <iostream>
#include "list.h"
#include "input.h"
using namespace std;
int main()
{
try {
List l;
// "enter a list of values"
l.Input();
// "display the list"
l.Display();
// "sort and redisplay the list"
l.BubbleSort();
l.Display();
// "display the average and median"
cout << "Median: " << l.Median() << endl;
cout << "Average: " << l.Average() << endl;
// "resize the list to a larger size"
long x = ReadValue<long>("New Size? ");
l.Resize(x);
// "display then resize to a smaller size"
l.Display();
x = ReadValue<long>("New Size? ");
l.Resize(x);
// "redisplay"
l.Display();
}
catch (const char* s) {
cerr << s << endl;
}
return 0;
}
BIN
View File
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
CMakeLists.txt not found in /Users/austin/Documents/School/Summer 2022/CSC 122/ListClass Select CMakeLists.txt
BIN
View File
Binary file not shown.
@@ -0,0 +1,284 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 55;
objects = {
/* Begin PBXBuildFile section */
D9284A732877728B00E2460C /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D9284A722877728B00E2460C /* main.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
D9284A6D2877728B00E2460C /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
D9284A6F2877728B00E2460C /* Midterm */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Midterm; sourceTree = BUILT_PRODUCTS_DIR; };
D9284A722877728B00E2460C /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
D9284A7C28777B2800E2460C /* input.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = input.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
D9284A6C2877728B00E2460C /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
D9284A662877728B00E2460C = {
isa = PBXGroup;
children = (
D9284A712877728B00E2460C /* Midterm */,
D9284A702877728B00E2460C /* Products */,
);
sourceTree = "<group>";
};
D9284A702877728B00E2460C /* Products */ = {
isa = PBXGroup;
children = (
D9284A6F2877728B00E2460C /* Midterm */,
);
name = Products;
sourceTree = "<group>";
};
D9284A712877728B00E2460C /* Midterm */ = {
isa = PBXGroup;
children = (
D9284A7C28777B2800E2460C /* input.h */,
D9284A722877728B00E2460C /* main.cpp */,
);
path = Midterm;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
D9284A6E2877728B00E2460C /* Midterm */ = {
isa = PBXNativeTarget;
buildConfigurationList = D9284A762877728B00E2460C /* Build configuration list for PBXNativeTarget "Midterm" */;
buildPhases = (
D9284A6B2877728B00E2460C /* Sources */,
D9284A6C2877728B00E2460C /* Frameworks */,
D9284A6D2877728B00E2460C /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = Midterm;
productName = Midterm;
productReference = D9284A6F2877728B00E2460C /* Midterm */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
D9284A672877728B00E2460C /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastUpgradeCheck = 1340;
TargetAttributes = {
D9284A6E2877728B00E2460C = {
CreatedOnToolsVersion = 13.4.1;
};
};
};
buildConfigurationList = D9284A6A2877728B00E2460C /* Build configuration list for PBXProject "Midterm" */;
compatibilityVersion = "Xcode 13.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = D9284A662877728B00E2460C;
productRefGroup = D9284A702877728B00E2460C /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
D9284A6E2877728B00E2460C /* Midterm */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
D9284A6B2877728B00E2460C /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D9284A732877728B00E2460C /* main.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
D9284A742877728B00E2460C /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
D9284A752877728B00E2460C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
};
name = Release;
};
D9284A772877728B00E2460C /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = N3GD25M5J3;
ENABLE_HARDENED_RUNTIME = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
D9284A782877728B00E2460C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = N3GD25M5J3;
ENABLE_HARDENED_RUNTIME = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
D9284A6A2877728B00E2460C /* Build configuration list for PBXProject "Midterm" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D9284A742877728B00E2460C /* Debug */,
D9284A752877728B00E2460C /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
D9284A762877728B00E2460C /* Build configuration list for PBXNativeTarget "Midterm" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D9284A772877728B00E2460C /* Debug */,
D9284A782877728B00E2460C /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = D9284A672877728B00E2460C /* Project object */;
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "1D545788-56B4-4EEB-A938-51074884970F"
type = "1"
version = "2.0">
</Bucket>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Midterm.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
+46
View File
@@ -0,0 +1,46 @@
#include <iostream>
#include <climits>
#include <string>
template <typename inputType>
inputType ReadValue(std::string prompt)
{
inputType returnValue = 0;
std::cout << prompt;
std::cin >> returnValue;
while (std::cin.fail())
{
std::cout << "Error! Cannot read input.\n";
std::cin.clear();
std::cin.ignore(INT_MAX, '\n');
std::cout << prompt;
std::cin >> returnValue;
}
return returnValue;
}
template <typename inputType>
inputType ReadValue(std::string prompt, inputType minValue)
{
inputType returnValue = 0;
returnValue = ReadValue<inputType>(prompt);
while (returnValue < minValue)
{
std::cout << "Error! Value must be >= " << minValue << std::endl;
returnValue = ReadValue<inputType>(prompt);
}
return returnValue;
}
template <typename inputType>
inputType ReadValue(std::string prompt, inputType minValue, inputType maxValue)
{
inputType returnValue = 0;
returnValue = ReadValue<inputType>(prompt, minValue);
while (returnValue > maxValue)
{
std::cout << "Error! Value must be <= " << maxValue << std::endl;
returnValue = ReadValue<inputType>(prompt, minValue);
}
return returnValue;
}
+49
View File
@@ -0,0 +1,49 @@
//
// main.cpp
// Midterm
//
// Created by Austin Bennett on 7/7/22.
//
/*
Redo question number 3 with these changes. Instead of dynamically allocating an array to store the data, your program will will an STL array. Even numbers will also be copied to an STL array. The input of the data and copying of even numbers will require the program to start at the beginning of the array and walk thorugh the values to the end. This must be done using iterators.
*/
#include <iostream>
#include <array>
#include <iterator>
#include <cmath>
#include "input.h"
using namespace std;
int main() {
array<int, 5> arr;
array<int, 5> evenArr;
array<int, 5>::iterator ptr;
array<int, 5>::iterator evenPtr = evenArr.begin();
for (ptr = arr.begin(); ptr < arr.end(); ptr++) {
*ptr = ReadValue<int>("Value: ");
}
// for (ptr = arr.begin(); ptr < arr.end(); ptr++) {
// cout << *ptr;
// }
for (ptr = arr.begin(); ptr < arr.end(); ptr++) {
if (*ptr % 2 == 0) {
*evenPtr = *ptr;
evenPtr++;
} else {
*evenPtr = NULL;
}
}
for (evenPtr = evenArr.begin(); *evenPtr != NULL; evenPtr++) {
cout << *evenPtr;
}
return 0;
}
+71
View File
@@ -0,0 +1,71 @@
### 1. When passing a C-style string as a parameter to a function - is the parameter passed by reference or default?
```
reference
```
### 2. When allocating the size of a C-style string, assume you want to store the string, "Hello, World!". What is the minimum size of the string you would need to allocate. Show how you would declare the string.
```
The minimum size would be 12 [11 for Hello World! and 1 for the null pointer]
```
```
char s[] = "Hello World!";
OR
char* s = "Hello World!";
```
# 3. TODO
# 4. TODO
### 5. What is the difference between composition and inheritence?
```
Composition is a "has-a" relationship while inheritence is a "is-a". Inheritance BASICALLY is a more strict relationship with composition allows for more flexiblity
```
### 6. What is polymorphism? Be sure to include what role virtual functions play in this and the difference between a virtual and pure virtual funciton. Be sure to include the defintion of an abstract base class.
```
Polymorphism allows the same function or object can act differently in different situations.
```
```
Virtual functions are declared by using the keyword "virtual" and return either int, float, or void. They are able to be "overwritten" to return something else.
```
```
The difference between a virtual function and a pure virtual function is that a pure virtual function is that when the function has no defintion.
```
```
An abstract base class is a class that can represent general concepts which can be used as a base for more concrete classes.
```
### 7. Assume that class B is derived publicly from class A which is abstract. The member functions that are private in class A will be private/protected/public/not directly accessible in class B.
```
not directly accesible in class B
```
### 8. Assume that you have a class that has an integer pointer as a private member. One of the member functions will dynamically allocate memory memory and assign the address to that member. Assume that an object of that class type is instantiated and the funtion called to allocate memory. When the object reaches the end of it's scope - will the memory that has been allocated be released automatically? If not, how would you create a mechanism to accomplish this. Be specific.
```
It will not. So we can use a destructor to get rid of that dynamically allocated memory
```
```
~Class() {
delete var;
}
```
### 9. What purpose does a copy constructor serve? Under what circumstances is it required?
```
a copy constructor is a function that initializes an object using another object of the same class. You what to use it when you want to duplicate an object.
```
# 10. Create a class that will store a list of names. Your class needs to include a function that will return the name that appears first aphabetically, and another function that should return the name that appears last alphabetically. You also need to include a function that will sort the list alphabetically. The class does not need to be case insensitive. The three functions should make use of the algorithms discussed in this class.
+8
View File
@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
+2
View File
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/NumericOutput.iml" filepath="$PROJECT_DIR$/.idea/NumericOutput.iml" />
</modules>
</component>
</project>
+6
View File
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.22)
project(NumericOutput)
set(CMAKE_CXX_STANDARD 14)
add_executable(NumericOutput main.cpp)

Some files were not shown because too many files have changed in this diff Show More