diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Bachelor/Prog2/Prakt2/geomObj | |
| download | Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.gz Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.bz2 | |
Diffstat (limited to 'Bachelor/Prog2/Prakt2/geomObj')
23 files changed, 422 insertions, 0 deletions
diff --git a/Bachelor/Prog2/Prakt2/geomObj/.cdtbuild b/Bachelor/Prog2/Prakt2/geomObj/.cdtbuild new file mode 100644 index 0000000..e0c01e4 --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/.cdtbuild @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?fileVersion 2.1.0?>
+
+<ManagedProjectBuildInfo>
+<project id="geomObj.cdt.managedbuild.target.gnu.exe.438729764" name="Executable (Gnu)" projectType="cdt.managedbuild.target.gnu.exe">
+<configuration id="cdt.managedbuild.config.gnu.exe.debug.63593985" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug" artifactName="geomObj" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" cleanCommand="rm -rf">
+<toolChain superClass="cdt.managedbuild.toolchain.gnu.exe.debug" id="cdt.managedbuild.toolchain.gnu.exe.debug.2094845" name="GCC Tool Chain">
+<tool superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug" id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1451406840" name="GCC C Compiler"/>
+<tool superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug" id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1170301199" name="GCC C++ Compiler"/>
+<tool superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug" id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.2024820330" name="GCC C Linker"/>
+<tool superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug" id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.320388229" name="GCC C++ Linker"/>
+<tool superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug" id="cdt.managedbuild.tool.gnu.assembler.exe.debug.1476595339" name="GCC Assembler"/>
+</toolChain>
+</configuration>
+<configuration id="cdt.managedbuild.config.gnu.exe.release.634623059" name="Release" parent="cdt.managedbuild.config.gnu.exe.release" artifactName="geomObj" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" cleanCommand="rm -rf">
+<toolChain superClass="cdt.managedbuild.toolchain.gnu.exe.release" id="cdt.managedbuild.toolchain.gnu.exe.release.1631051032" name="GCC Tool Chain">
+<tool superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release" id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.379225803" name="GCC C Compiler"/>
+<tool superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release" id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.498605140" name="GCC C++ Compiler"/>
+<tool superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release" id="cdt.managedbuild.tool.gnu.c.linker.exe.release.532531920" name="GCC C Linker"/>
+<tool superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release" id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.1998885769" name="GCC C++ Linker"/>
+<tool superClass="cdt.managedbuild.tool.gnu.assembler.exe.release" id="cdt.managedbuild.tool.gnu.assembler.exe.release.1741496889" name="GCC Assembler"/>
+</toolChain>
+</configuration>
+</project>
+</ManagedProjectBuildInfo>
diff --git a/Bachelor/Prog2/Prakt2/geomObj/.cdtproject b/Bachelor/Prog2/Prakt2/geomObj/.cdtproject new file mode 100644 index 0000000..82c36e0 --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/.cdtproject @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse-cdt version="2.0"?>
+
+<cdtproject id="org.eclipse.cdt.managedbuilder.core.managedMake">
+<extension point="org.eclipse.cdt.core.ScannerInfoProvider" id="org.eclipse.cdt.managedbuilder.core.ManagedBuildManager"/>
+<extension point="org.eclipse.cdt.core.BinaryParser" id="org.eclipse.cdt.core.ELF"/>
+<data>
+<item id="cdt_indexer">
+<indexEnabled indexValue="true"/>
+<indexerProblemsEnabled indexProblemsValue="0"/>
+</item>
+<item id="org.eclipse.cdt.core.pathentry">
+<pathentry kind="src" path=""/>
+<pathentry kind="out" path=""/>
+<pathentry kind="con" path="org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER"/>
+</item>
+</data>
+</cdtproject>
diff --git a/Bachelor/Prog2/Prakt2/geomObj/.project b/Bachelor/Prog2/Prakt2/geomObj/.project new file mode 100644 index 0000000..166cc9d --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/.project @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>geomObj</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ </natures>
+</projectDescription>
diff --git a/Bachelor/Prog2/Prakt2/geomObj/Circle.cpp b/Bachelor/Prog2/Prakt2/geomObj/Circle.cpp new file mode 100644 index 0000000..14415bf --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Circle.cpp @@ -0,0 +1,27 @@ +#include "Circle.h"
+
+const double pi = 3.14159265358979;
+
+Circle::Circle()
+ :radius(.0)
+{
+}
+
+Circle::Circle(double newR)
+ :radius(newR)
+{
+}
+
+Circle::~Circle()
+{
+}
+
+double Circle::getArea()
+{
+ return (radius * radius * pi);
+}
+
+double Circle::getCircumference()
+{
+ return (2 * radius * pi);
+}
diff --git a/Bachelor/Prog2/Prakt2/geomObj/Circle.h b/Bachelor/Prog2/Prakt2/geomObj/Circle.h new file mode 100644 index 0000000..580b254 --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Circle.h @@ -0,0 +1,18 @@ +#ifndef _CIRCLE_H_
+#define _CIRCLE_H_
+
+#include "Shape.h"
+
+class Circle : public Shape
+{
+public:
+ Circle();
+ Circle(double);
+ virtual ~Circle();
+ virtual double getArea();
+ virtual double getCircumference();
+private:
+ const double radius;
+};
+
+#endif //_CIRCLE_H_
diff --git a/Bachelor/Prog2/Prakt2/geomObj/Debug/Circle.d b/Bachelor/Prog2/Prakt2/geomObj/Debug/Circle.d new file mode 100644 index 0000000..61b13d0 --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Debug/Circle.d @@ -0,0 +1,10 @@ +################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+Circle.d ./Circle.o: ../Circle.cpp ../Circle.h ../Shape.h
+
+../Circle.h:
+
+../Shape.h:
+
diff --git a/Bachelor/Prog2/Prakt2/geomObj/Debug/Rectangle.d b/Bachelor/Prog2/Prakt2/geomObj/Debug/Rectangle.d new file mode 100644 index 0000000..3cca9be --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Debug/Rectangle.d @@ -0,0 +1,10 @@ +################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+Rectangle.d ./Rectangle.o: ../Rectangle.cpp ../Rectangle.h ../Shape.h
+
+../Rectangle.h:
+
+../Shape.h:
+
diff --git a/Bachelor/Prog2/Prakt2/geomObj/Debug/Shape.d b/Bachelor/Prog2/Prakt2/geomObj/Debug/Shape.d new file mode 100644 index 0000000..3ca796d --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Debug/Shape.d @@ -0,0 +1,8 @@ +################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+Shape.d ./Shape.o: ../Shape.cpp ../Shape.h
+
+../Shape.h:
+
diff --git a/Bachelor/Prog2/Prakt2/geomObj/Debug/Square.d b/Bachelor/Prog2/Prakt2/geomObj/Debug/Square.d new file mode 100644 index 0000000..15e7998 --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Debug/Square.d @@ -0,0 +1,12 @@ +################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+Square.d ./Square.o: ../Square.cpp ../Square.h ../Rectangle.h ../Shape.h
+
+../Square.h:
+
+../Rectangle.h:
+
+../Shape.h:
+
diff --git a/Bachelor/Prog2/Prakt2/geomObj/Debug/geomObj b/Bachelor/Prog2/Prakt2/geomObj/Debug/geomObj Binary files differnew file mode 100644 index 0000000..809ba37 --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Debug/geomObj diff --git a/Bachelor/Prog2/Prakt2/geomObj/Debug/main.d b/Bachelor/Prog2/Prakt2/geomObj/Debug/main.d new file mode 100644 index 0000000..b5a4438 --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Debug/main.d @@ -0,0 +1,14 @@ +################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+main.d ./main.o: ../main.cpp ../Rectangle.h ../Shape.h ../Circle.h ../Square.h
+
+../Rectangle.h:
+
+../Shape.h:
+
+../Circle.h:
+
+../Square.h:
+
diff --git a/Bachelor/Prog2/Prakt2/geomObj/Debug/makefile b/Bachelor/Prog2/Prakt2/geomObj/Debug/makefile new file mode 100644 index 0000000..698fd9d --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Debug/makefile @@ -0,0 +1,30 @@ +################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+ROOT := ..
+
+-include $(ROOT)/makefile.init
+
+RM := rm -rf
+
+# All of the sources participating in the build are defined here
+-include sources.mk
+-include $(SUBDIRS:%=%/subdir.mk)
+-include objects.mk
+-include $(DEPS)
+-include $(ROOT)/makefile.defs
+
+all: geomObj
+
+geomObj: $(OBJS)
+ @echo 'Building target: $@'
+ g++ -o $@ $(OBJS) $(USER_OBJS) $(LIBS)
+ @echo 'Finished building: $@'
+
+clean:
+ -$(RM) $(OBJS) $(DEPS) geomObj
+
+.PHONY: all clean dependents
+
+-include $(ROOT)/makefile.targets
diff --git a/Bachelor/Prog2/Prakt2/geomObj/Debug/objects.mk b/Bachelor/Prog2/Prakt2/geomObj/Debug/objects.mk new file mode 100644 index 0000000..59a3b5b --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Debug/objects.mk @@ -0,0 +1,13 @@ +################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+LIBS :=
+USER_OBJS :=
+
+
+OBJS := \
+ $(C_SRCS:$(ROOT)/%.c=%.o) $(C_UPPER_SRCS:$(ROOT)/%.C=%.o) $(CC_SRCS:$(ROOT)/%.cc=%.o) $(CXX_SRCS:$(ROOT)/%.cxx=%.o) $(CPP_SRCS:$(ROOT)/%.cpp=%.o) $(S_SRCS:$(ROOT)/%.s=%.o) $(S_UPPER_SRCS:$(ROOT)/%.S=%.o)
+
+DEPS := \
+ $(C_SRCS:$(ROOT)/%.c=%.d) $(C_UPPER_SRCS:$(ROOT)/%.C=%.d) $(CC_SRCS:$(ROOT)/%.cc=%.d) $(CXX_SRCS:$(ROOT)/%.cxx=%.d) $(CPP_SRCS:$(ROOT)/%.cpp=%.d) $(S_SRCS:$(ROOT)/%.s=%.d) $(S_UPPER_SRCS:$(ROOT)/%.S=%.d)
\ No newline at end of file diff --git a/Bachelor/Prog2/Prakt2/geomObj/Debug/sources.mk b/Bachelor/Prog2/Prakt2/geomObj/Debug/sources.mk new file mode 100644 index 0000000..357bfc1 --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Debug/sources.mk @@ -0,0 +1,16 @@ +################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+C_SRCS :=
+C_UPPER_SRCS :=
+CC_SRCS :=
+CXX_SRCS :=
+CPP_SRCS :=
+S_SRCS :=
+S_UPPER_SRCS :=
+
+# Every subdirectory with source files must be described here
+SUBDIRS := \
+. \
+
diff --git a/Bachelor/Prog2/Prakt2/geomObj/Debug/subdir.mk b/Bachelor/Prog2/Prakt2/geomObj/Debug/subdir.mk new file mode 100644 index 0000000..f9a4a41 --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Debug/subdir.mk @@ -0,0 +1,48 @@ +################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+S_UPPER_SRCS += \
+${addprefix $(ROOT)/, \
+}
+
+CPP_SRCS += \
+${addprefix $(ROOT)/, \
+Circle.cpp \
+Rectangle.cpp \
+Shape.cpp \
+Square.cpp \
+main.cpp \
+}
+
+CC_SRCS += \
+${addprefix $(ROOT)/, \
+}
+
+C_SRCS += \
+${addprefix $(ROOT)/, \
+}
+
+C_UPPER_SRCS += \
+${addprefix $(ROOT)/, \
+}
+
+CXX_SRCS += \
+${addprefix $(ROOT)/, \
+}
+
+S_SRCS += \
+${addprefix $(ROOT)/, \
+}
+
+# Each subdirectory must supply rules for building sources it contributes
+%.o: $(ROOT)/%.cpp
+ @echo 'Building file: $<'
+ @echo g++ -O0 -g3 -Wall -c -fmessage-length=0 -o$@ $<
+ @g++ -O0 -g3 -Wall -c -fmessage-length=0 -o$@ $< && \
+ echo -n $(@:%.o=%.d) $(dir $@) > $(@:%.o=%.d) && \
+ g++ -MM -MG -P -w -O0 -g3 -Wall -c -fmessage-length=0 $< >> $(@:%.o=%.d)
+ @echo 'Finished building: $<'
+ @echo ' '
+
+
diff --git a/Bachelor/Prog2/Prakt2/geomObj/Rectangle.cpp b/Bachelor/Prog2/Prakt2/geomObj/Rectangle.cpp new file mode 100644 index 0000000..cc48ae2 --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Rectangle.cpp @@ -0,0 +1,25 @@ +#include "Rectangle.h"
+
+Rectangle::Rectangle()
+ :sideA(.0),sideB(.0)
+{
+}
+
+Rectangle::~Rectangle()
+{
+}
+
+Rectangle::Rectangle(double newA, double newB)
+ :sideA(newA),sideB(newB)
+{
+}
+
+double Rectangle::getCircumference()
+{
+ return 2 * (sideA + sideB);
+}
+
+double Rectangle::getArea()
+{
+ return sideA*sideB;
+}
diff --git a/Bachelor/Prog2/Prakt2/geomObj/Rectangle.h b/Bachelor/Prog2/Prakt2/geomObj/Rectangle.h new file mode 100644 index 0000000..586110a --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Rectangle.h @@ -0,0 +1,19 @@ +#ifndef _RECTANGLE_H_
+#define _RECTANGLE_H_
+
+#include "Shape.h"
+
+class Rectangle : public Shape
+{
+public:
+ Rectangle();
+ Rectangle(double,double);
+ virtual ~Rectangle();
+ virtual double getArea();
+ virtual double getCircumference();
+private:
+ const double sideA;
+ const double sideB;
+};
+
+#endif //_RECTANGLE_H_
diff --git a/Bachelor/Prog2/Prakt2/geomObj/Shape.cpp b/Bachelor/Prog2/Prakt2/geomObj/Shape.cpp new file mode 100644 index 0000000..8eb43e5 --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Shape.cpp @@ -0,0 +1,14 @@ +#include "Shape.h"
+
+Shape::Shape()
+{
+}
+
+Shape::~Shape()
+{
+}
+
+double Shape::operator-(Shape* toSub)
+{
+ return (this->getArea() - toSub->getArea());
+}
diff --git a/Bachelor/Prog2/Prakt2/geomObj/Shape.h b/Bachelor/Prog2/Prakt2/geomObj/Shape.h new file mode 100644 index 0000000..481c2be --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Shape.h @@ -0,0 +1,14 @@ +#ifndef _SHAPE_H_
+#define _SHAPE_H_
+
+class Shape
+{
+public:
+ Shape();
+ virtual ~Shape();
+ virtual double getCircumference() = 0;
+ virtual double getArea() = 0;
+ double operator-(Shape*);
+};
+
+#endif //_SHAPE_H_
diff --git a/Bachelor/Prog2/Prakt2/geomObj/Square.cpp b/Bachelor/Prog2/Prakt2/geomObj/Square.cpp new file mode 100644 index 0000000..3bd6682 --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Square.cpp @@ -0,0 +1,25 @@ +#include "Square.h"
+
+Square::Square()
+ :length(.0)
+{
+}
+
+Square::Square(double newlength)
+:length(newlength)
+{
+}
+
+Square::~Square()
+{
+}
+
+double Square::getArea()
+{
+ return length*length;
+}
+
+double Square::getCircumference()
+{
+ return 2 * (length + length);
+}
diff --git a/Bachelor/Prog2/Prakt2/geomObj/Square.h b/Bachelor/Prog2/Prakt2/geomObj/Square.h new file mode 100644 index 0000000..022483b --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/Square.h @@ -0,0 +1,18 @@ +#ifndef _SQUARE_H_
+#define _SQUARE_H_
+
+#include "Rectangle.h"
+
+class Square : public Rectangle
+{
+public:
+ Square();
+ Square(double);
+ virtual ~Square();
+ virtual double getCircumference();
+ virtual double getArea();
+private:
+ const double length;
+};
+
+#endif //_SQUARE_H_
diff --git a/Bachelor/Prog2/Prakt2/geomObj/geomObj.zip b/Bachelor/Prog2/Prakt2/geomObj/geomObj.zip Binary files differnew file mode 100644 index 0000000..cad5044 --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/geomObj.zip diff --git a/Bachelor/Prog2/Prakt2/geomObj/main.cpp b/Bachelor/Prog2/Prakt2/geomObj/main.cpp new file mode 100644 index 0000000..e81de02 --- /dev/null +++ b/Bachelor/Prog2/Prakt2/geomObj/main.cpp @@ -0,0 +1,39 @@ +#include <iostream>
+#include "Rectangle.h"
+#include "Circle.h"
+#include "Square.h"
+
+using std::cout;
+using std::endl;
+
+int main()
+{
+ Circle circle(15.0);
+ Rectangle rectangle(3.0,4.0);
+ Square square(4.2);
+
+ int n,j;
+
+ Shape* ptrArray[3];
+
+ ptrArray[0]=&circle;
+ ptrArray[1]=&rectangle;
+ ptrArray[2]=□
+
+ for (n=0;n<3;n++)
+ {
+ cout << "Area: "<< (ptrArray[n]->getArea()) << " Circumference: "
+ << (ptrArray[n]->getCircumference()) << endl;
+ }
+
+ for (n=0;n<3;n++)
+ {
+ for (j=0;j<3;j++)
+ {
+ cout << "Difference: "
+ << (ptrArray[j]->getArea() - ptrArray[n]->getArea()) << endl;
+ }
+ }
+
+ return 0;
+}
|
