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.
+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