From 5123ae2bd3e8c201e95f8ebed3309509ad8616f6 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Tue, 4 Apr 2017 15:00:42 +0200 Subject: [PATCH] [CCV] Added three test programs for CCV exercise 1 Signed-off-by: Jim Martens --- ccv/sheet1/AskInteger.cpp | 25 +++++++++++++++++++++++++ ccv/sheet1/Rectangle.cpp | 30 ++++++++++++++++++++++++++++++ ccv/sheet1/hello.cpp | 12 ++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 ccv/sheet1/AskInteger.cpp create mode 100644 ccv/sheet1/Rectangle.cpp create mode 100644 ccv/sheet1/hello.cpp diff --git a/ccv/sheet1/AskInteger.cpp b/ccv/sheet1/AskInteger.cpp new file mode 100644 index 0000000..233fafd --- /dev/null +++ b/ccv/sheet1/AskInteger.cpp @@ -0,0 +1,25 @@ +// +// Created by jim on 4/4/17. +// +#include +using namespace std; + +int main() +{ + int input; + cout << "Bitte geben Sie eine Zahl ein." << endl; + cin >> input; + if (input > 9) + { + cout << input << " ist größer gleich 10." << endl; + } + else if (input >= 0) + { + cout << input << " liegt zwischen einschließlich 0 und 9." << endl; + } + else + { + cout << input << " ist negativ." << endl; + } + return 0; +} diff --git a/ccv/sheet1/Rectangle.cpp b/ccv/sheet1/Rectangle.cpp new file mode 100644 index 0000000..7d30a0c --- /dev/null +++ b/ccv/sheet1/Rectangle.cpp @@ -0,0 +1,30 @@ +// +// Created by jim on 4/4/17. +// +#include +using namespace std; + +class Rectangle +{ +private: + unsigned int width; + unsigned int height; + +public: + Rectangle(unsigned int width, unsigned int height) + { + this->width = width; + this->height = height; + } + + unsigned int area() + { + return this->height * this->width; + } +}; + +int main() +{ + Rectangle* rec = new Rectangle(10, 20); + cout << rec->area() << endl; +} diff --git a/ccv/sheet1/hello.cpp b/ccv/sheet1/hello.cpp new file mode 100644 index 0000000..dd473d6 --- /dev/null +++ b/ccv/sheet1/hello.cpp @@ -0,0 +1,12 @@ +// +// Created by jim on 4/4/17. +// +#include +#include +using namespace std; + +int main() +{ + std::cout << "Hello world!"; + return 0; +}