mal sehen

This commit is contained in:
Johannes Theiner 2018-06-14 16:22:51 +02:00
parent 37637fa912
commit c318f26d43
12 changed files with 177 additions and 437 deletions

View File

@ -1,11 +1,15 @@
#include <iostream> #include <iostream>
#include <cmath> #include <cmath>
#include "AnsiConsole.h" #include "../helpers/AnsiConsole.h"
struct Position { struct Position {
int x; int x;
int y; int y;
Position(int x_=0, int y_=0){ x=x_;y=y_;}
Position(int x_ = 0, int y_ = 0) {
x = x_;
y = y_;
}
}; };
class Point { class Point {
@ -13,6 +17,7 @@ protected:
Position _position; Position _position;
public: public:
Point(int x = 0, int y = 0); Point(int x = 0, int y = 0);
void draw(); void draw();
}; };
@ -30,6 +35,7 @@ protected:
int _radius; int _radius;
public: public:
Circle(int x = 0, int y = 0, int radius = 0); Circle(int x = 0, int y = 0, int radius = 0);
void draw(); void draw();
}; };
@ -58,8 +64,28 @@ void Circle::draw(){
} }
} }
int main(int argc, char **argv) class Rectangle {
{ protected:
Position position;
int width;
int height;
public:
Rectangle(int x = 0, int y = 0, int width = 0, int height = 0);
void draw();
};
Rectangle::Rectangle(int x, int y, int width, int height) {
position = Position(x, y);
this->width = width;
this->height = height;
}
void Rectangle::draw() {
}
int main(int argc, char **argv) {
// x=1 and y=1 is the upper left corner // x=1 and y=1 is the upper left corner
// x and y are more like column and row // x and y are more like column and row
ansiConsole.printText(5, 5, "Hello, World!"); ansiConsole.printText(5, 5, "Hello, World!");

View File

@ -1,245 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
65413E911CEB65E5008BE849 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65413E901CEB65E5008BE849 /* main.cpp */; };
65413E991CEB6612008BE849 /* OneByOneMatrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65413E971CEB6612008BE849 /* OneByOneMatrix.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
65413E8B1CEB65E5008BE849 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
65413E8D1CEB65E5008BE849 /* CopyOnWrite */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = CopyOnWrite; sourceTree = BUILT_PRODUCTS_DIR; };
65413E901CEB65E5008BE849 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
65413E971CEB6612008BE849 /* OneByOneMatrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OneByOneMatrix.cpp; sourceTree = "<group>"; };
65413E981CEB6612008BE849 /* OneByOneMatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OneByOneMatrix.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
65413E8A1CEB65E5008BE849 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
65413E841CEB65E5008BE849 = {
isa = PBXGroup;
children = (
65413E8F1CEB65E5008BE849 /* CopyOnWrite */,
65413E8E1CEB65E5008BE849 /* Products */,
);
sourceTree = "<group>";
};
65413E8E1CEB65E5008BE849 /* Products */ = {
isa = PBXGroup;
children = (
65413E8D1CEB65E5008BE849 /* CopyOnWrite */,
);
name = Products;
sourceTree = "<group>";
};
65413E8F1CEB65E5008BE849 /* CopyOnWrite */ = {
isa = PBXGroup;
children = (
65413E901CEB65E5008BE849 /* main.cpp */,
65413E971CEB6612008BE849 /* OneByOneMatrix.cpp */,
65413E981CEB6612008BE849 /* OneByOneMatrix.h */,
);
path = CopyOnWrite;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
65413E8C1CEB65E5008BE849 /* CopyOnWrite */ = {
isa = PBXNativeTarget;
buildConfigurationList = 65413E941CEB65E5008BE849 /* Build configuration list for PBXNativeTarget "CopyOnWrite" */;
buildPhases = (
65413E891CEB65E5008BE849 /* Sources */,
65413E8A1CEB65E5008BE849 /* Frameworks */,
65413E8B1CEB65E5008BE849 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = CopyOnWrite;
productName = CopyOnWrite;
productReference = 65413E8D1CEB65E5008BE849 /* CopyOnWrite */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
65413E851CEB65E5008BE849 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0620;
ORGANIZATIONNAME = HSEL;
TargetAttributes = {
65413E8C1CEB65E5008BE849 = {
CreatedOnToolsVersion = 6.2;
};
};
};
buildConfigurationList = 65413E881CEB65E5008BE849 /* Build configuration list for PBXProject "CopyOnWrite" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 65413E841CEB65E5008BE849;
productRefGroup = 65413E8E1CEB65E5008BE849 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
65413E8C1CEB65E5008BE849 /* CopyOnWrite */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
65413E891CEB65E5008BE849 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
65413E911CEB65E5008BE849 /* main.cpp in Sources */,
65413E991CEB6612008BE849 /* OneByOneMatrix.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
65413E921CEB65E5008BE849 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
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 = 10.9;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
65413E931CEB65E5008BE849 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
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 = gnu99;
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 = 10.9;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
};
name = Release;
};
65413E951CEB65E5008BE849 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
65413E961CEB65E5008BE849 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
65413E881CEB65E5008BE849 /* Build configuration list for PBXProject "CopyOnWrite" */ = {
isa = XCConfigurationList;
buildConfigurations = (
65413E921CEB65E5008BE849 /* Debug */,
65413E931CEB65E5008BE849 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
65413E941CEB65E5008BE849 /* Build configuration list for PBXNativeTarget "CopyOnWrite" */ = {
isa = XCConfigurationList;
buildConfigurations = (
65413E951CEB65E5008BE849 /* Debug */,
65413E961CEB65E5008BE849 /* Release */,
);
defaultConfigurationIsVisible = 0;
};
/* End XCConfigurationList section */
};
rootObject = 65413E851CEB65E5008BE849 /* Project object */;
}

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:CopyOnWrite.xcodeproj">
</FileRef>
</Workspace>

View File

@ -1,88 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0620"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "65413E8C1CEB65E5008BE849"
BuildableName = "CopyOnWrite"
BlueprintName = "CopyOnWrite"
ReferencedContainer = "container:CopyOnWrite.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "65413E8C1CEB65E5008BE849"
BuildableName = "CopyOnWrite"
BlueprintName = "CopyOnWrite"
ReferencedContainer = "container:CopyOnWrite.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "65413E8C1CEB65E5008BE849"
BuildableName = "CopyOnWrite"
BlueprintName = "CopyOnWrite"
ReferencedContainer = "container:CopyOnWrite.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "65413E8C1CEB65E5008BE849"
BuildableName = "CopyOnWrite"
BlueprintName = "CopyOnWrite"
ReferencedContainer = "container:CopyOnWrite.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -1,22 +0,0 @@
<?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>CopyOnWrite.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>65413E8C1CEB65E5008BE849</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>

View File

@ -0,0 +1,48 @@
#include <iostream>
#include "LargeCowMatrix.h"
int LargeCowMatrix::instanceCounter = 0;
LargeCowMatrix::LargeCowMatrix() : value(-1), referenceCounter(0){
instanceCounter++;
}
LargeCowMatrix::LargeCowMatrix(int value) : value(value), referenceCounter(0){
instanceCounter++;
}
LargeCowMatrix::LargeCowMatrix(const LargeCowMatrix& source) : value(source.value), referenceCounter(source.referenceCounter){
instanceCounter++;
}
LargeCowMatrix::~LargeCowMatrix() {
instanceCounter--;
}
LargeCowMatrix::operator int() {
return value;
}
LargeCowMatrix LargeCowMatrix::operator+(const LargeCowMatrix &other) {
return LargeCowMatrix(value + other.value);
}
LargeCowMatrix &LargeCowMatrix::operator++(int) {
value++;
return *this;
}
bool LargeCowMatrix::operator==(const LargeCowMatrix &other) {
return this->value == other.value;
}
bool LargeCowMatrix::operator!=(const LargeCowMatrix &other) {
return !(*this==other);
}
bool LargeCowMatrix::instanceCountExceeds(int max) {
bool result = instanceCounter>max;
if(result)
std::cout << LargeCowMatrix::instanceCounter << " > max=" << max << std::endl;
return result;
}

View File

@ -0,0 +1,26 @@
#ifndef TEST_BUILD_LARGECOWMATRIX_H
#define TEST_BUILD_LARGECOWMATRIX_H
class LargeCowMatrix {
int value;
int referenceCounter;
static int instanceCounter;
public:
LargeCowMatrix();
explicit LargeCowMatrix(int value);
LargeCowMatrix(const LargeCowMatrix&);
~LargeCowMatrix();
explicit operator int();
LargeCowMatrix operator+(const LargeCowMatrix & other);
LargeCowMatrix& operator ++(int);
bool operator==(const LargeCowMatrix& other);
bool operator!=(const LargeCowMatrix& other);
static bool instanceCountExceeds(int max);
};
#endif //TEST_BUILD_LARGECOWMATRIX_H

View File

@ -14,20 +14,17 @@
int OneByOneMatrix::s_instanceCounter=0; int OneByOneMatrix::s_instanceCounter=0;
OneByOneMatrix::OneByOneMatrix() OneByOneMatrix::OneByOneMatrix() : m_value(-1), m_referenceCounter(0)
: m_value(-1), m_referenceCounter(0)
{ {
s_instanceCounter++; s_instanceCounter++;
} }
OneByOneMatrix::OneByOneMatrix(int initialValue) OneByOneMatrix::OneByOneMatrix(int initialValue) : m_value(initialValue), m_referenceCounter(0)
: m_value(initialValue), m_referenceCounter(0)
{ {
s_instanceCounter++; s_instanceCounter++;
} }
OneByOneMatrix::OneByOneMatrix(const OneByOneMatrix& source) OneByOneMatrix::OneByOneMatrix(const OneByOneMatrix& source) : m_value(source.m_value), m_referenceCounter(source.m_referenceCounter)
: m_value(source.m_value), m_referenceCounter(source.m_referenceCounter)
{ {
s_instanceCounter++; s_instanceCounter++;
} }

View File

@ -34,9 +34,5 @@ public:
// imagine this class as an abstraction for very large matrices // imagine this class as an abstraction for very large matrices
class LargeCowMatrix {
};
#endif /* defined(__CopyOnWrite__OneByOneMatrix__) */ #endif /* defined(__CopyOnWrite__OneByOneMatrix__) */

View File

@ -8,14 +8,14 @@
#include <iostream> #include <iostream>
#include "OneByOneMatrix.h" #include "OneByOneMatrix.h"
#include "LargeCowMatrix.h"
int failCounter=0; int failCounter=0;
typedef int NumberType; //typedef int NumberType;
//typedef OneByOneMatrix NumberType; //typedef OneByOneMatrix NumberType;
//typedef LargeCowMatrix NumberType; typedef LargeCowMatrix NumberType;
void simpleTests(){ void simpleTests(){

View File

@ -15,6 +15,11 @@ set(UDEF_TESTAT UserDefinedTypesTestat)
set(UDEF_TESTAT_SOURCE 04_UDEF/Testat/Testat.cpp) set(UDEF_TESTAT_SOURCE 04_UDEF/Testat/Testat.cpp)
add_executable(${UDEF_TESTAT} ${UDEF_TESTAT_SOURCE}) add_executable(${UDEF_TESTAT} ${UDEF_TESTAT_SOURCE})
set(05_SHAPES 05_Shapes)
set(05_SHAPES_SOURCE 05_OO/shapes_main.cpp)
add_executable(${05_SHAPES} helpers/AnsiConsole.cpp ${05_SHAPES_SOURCE})
set(SEQUENCE_DIAGRAM SequenzDiagram) set(SEQUENCE_DIAGRAM SequenzDiagram)
set(SEQUENCE_DIAGRAM_SOURCE 11_PUTT/05_OO_b/main.cpp) set(SEQUENCE_DIAGRAM_SOURCE 11_PUTT/05_OO_b/main.cpp)
add_executable(${SEQUENCE_DIAGRAM} 11_PUTT/05_OO_b/SequenceDiagramCreator.cpp ${SEQUENCE_DIAGRAM_SOURCE}) add_executable(${SEQUENCE_DIAGRAM} 11_PUTT/05_OO_b/SequenceDiagramCreator.cpp ${SEQUENCE_DIAGRAM_SOURCE})
@ -22,3 +27,7 @@ add_executable(${SEQUENCE_DIAGRAM} 11_PUTT/05_OO_b/SequenceDiagramCreator.cpp ${
set(LCDDISPLAY LCDDisplay) set(LCDDISPLAY LCDDisplay)
set(LCDDISPLAY_SOURCE 11_PUTT/02_Ment/LCDDisplay.cpp) set(LCDDISPLAY_SOURCE 11_PUTT/02_Ment/LCDDisplay.cpp)
add_executable(${LCDDISPLAY} ${LCDDISPLAY_SOURCE}) add_executable(${LCDDISPLAY} ${LCDDISPLAY_SOURCE})
set(COPY_ON_WRITE CopyOnWrite)
set(COPY_ON_WRITE_SOURCE 11_PUTT/CopyOnWrite/main.cpp)
add_executable(${COPY_ON_WRITE} 11_PUTT/CopyOnWrite/OneByOneMatrix.cpp 11_PUTT/CopyOnWrite/LargeCowMatrix.cpp ${COPY_ON_WRITE_SOURCE})