Skip to content
Snippets Groups Projects
Commit d0335fc2 authored by Adrian Josef Waldvogel's avatar Adrian Josef Waldvogel
Browse files

Übungsprogramm 22 abgeschlossen

parent 05e06b13
No related branches found
No related tags found
No related merge requests found
Showing with 253 additions and 0 deletions
{
"configurations": [
{
"name": "windows-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "C:/msys64/ucrt64/bin/gcc.exe",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "windows-gcc-x64",
"compilerArgs": [
""
]
}
],
"version": 4
}
\ No newline at end of file
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": true,
"cwd": "c:/Users/adria/Documents/Schule/OST/Repositories/praktika-grulait/Pruefungsvorbereitung/Programme/Uebungsprogramm22",
"program": "c:/Users/adria/Documents/Schule/OST/Repositories/praktika-grulait/Pruefungsvorbereitung/Programme/Uebungsprogramm22/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
\ No newline at end of file
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false,
"files.associations": {
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"typeinfo": "cpp"
}
}
\ No newline at end of file
#include <iostream>
#include "Door.h"
Door::Door(std::string doorName) : name{doorName} {
std::cout << "Die Türe " << name << " wurde erstellt.\n";
}
void Door::open() {
opening();
std::cout << "Die Tür wurde geöffnet\n";
state = OFFEN;
}
void Door::close() {
closing();
std::cout << "Die Tür wurde geschlossen\n";
state = GESCHLOSSEN;
}
void Door::getDoorState() {
switch(state) {
case OFFEN:
std::cout << "Die Türe ist offen.\n";
break;
case GESCHLOSSEN:
std::cout << "Die Türe ist geschlossen.\n";
break;
}
}
// private methods
void Door::opening() {
while (position < 90) {
position++;
if (position % 10 == 0) {
std::cout << position << "\n";
}
}
}
void Door::closing() {
while (position > 0 ) {
position--;
if (position % 10 == 0) {
std::cout << position << "\n";
}
}
}
\ No newline at end of file
#pragma once
class Door {
public:
Door(std::string doorName);
std::string name;
void open();
void close();
void getDoorState();
int position{0};
private:
enum DoorStates{GESCHLOSSEN, OFFEN};
DoorStates state;
void opening();
void closing();
};
\ No newline at end of file
File added
File added
File added
#include <iostream>
#include "Door.h"
int eingabe() {
int funktion{0};
std::cout << "Funktion: ";
std::cin >> funktion;
return funktion;
}
int main() {
int funktion{0};
Door myDoor("Schlafzimmer");
std::cout << "Funktionen: 1) Tür öffnen, 2) Tür schliessen, 3) Türstatus abfragen, 4) Türnamen abfragen\n";
funktion = eingabe();
while (funktion != 0) {
switch (funktion) {
case 1:
myDoor.open();
break;
case 2:
myDoor.close();
break;
case 3:
myDoor.getDoorState();
break;
case 4:
std:: cout << "Die Türe heisst: " << myDoor.name << "\n";
break;
default:
std::cout << "Diese Funktion ist nicht zulässig.\n";
break;
}
funktion = eingabe();
}
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment