From 0d4f07c5bc4d26fde23a18126b000076d9fa18a6 Mon Sep 17 00:00:00 2001 From: Jan Meyer Date: Thu, 16 Apr 2026 08:33:48 +0200 Subject: [PATCH] vault backup: 2026-04-16 08:33:48 --- .obsidian/workspace.json | 21 ++++----------------- 00 Inbox/29605321 - OOP 4_16.md | 32 ++++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index f5d1aa4..cd15a9e 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -22,7 +22,7 @@ } }, { - "id": "e179fd2c20f4067e", + "id": "f2cbb43fcaaa6aec", "type": "leaf", "state": { "type": "markdown", @@ -34,20 +34,6 @@ "icon": "lucide-file", "title": "29605321 - OOP 4_16" } - }, - { - "id": "1e58a188bb5d367b", - "type": "leaf", - "state": { - "type": "markdown", - "state": { - "file": "10 Courses/02 - SoSe 2026/AT/29593952 - Regular Languages.md", - "mode": "source", - "source": false - }, - "icon": "lucide-file", - "title": "29593952 - Regular Languages" - } } ] } @@ -212,8 +198,10 @@ }, "active": "7a0e7b37bd89861d", "lastOpenFiles": [ - "00 Inbox/29595454 - Komplexe Zahlen und Eigenwertaufgaben.md", + "10 Courses/02 - SoSe 2026/AT/29593852 - Strings.md", + "10 Courses/02 - SoSe 2026/AT/29593952 - Regular Languages.md", "00 Inbox/29605321 - OOP 4_16.md", + "00 Inbox/29595454 - Komplexe Zahlen und Eigenwertaufgaben.md", "OOP - Apr", "10 Courses/02 - SoSe 2026/Mathe II/29595454 - Mathematik II.md", "20 Atlas/AT - Map of Content.md", @@ -227,7 +215,6 @@ "10 Courses/02 - SoSe 2026/Mathe II/29595454 - Mathematik II.md", "10 Courses/02 - SoSe 2026/AT/29593975 - Regular Expressions.md", "10 Courses/02 - SoSe 2026/AT/29593958 - Kleene star of languages.md", - "10 Courses/02 - SoSe 2026/AT/29593952 - Regular Languages.md", "10 Courses/02 - SoSe 2026/AT/29593940 - Formal Languages.md", "10 Courses/02 - SoSe 2026/AT/29593935 - Kleene Star & Kleene Plus.md", "10 Courses/02 - SoSe 2026/AT/29593929 - Alphabets.md", diff --git a/00 Inbox/29605321 - OOP 4_16.md b/00 Inbox/29605321 - OOP 4_16.md index d4804a0..553e9be 100644 --- a/00 Inbox/29605321 - OOP 4_16.md +++ b/00 Inbox/29605321 - OOP 4_16.md @@ -22,15 +22,39 @@ C approach of defining a Pokemon: ```C typedef struct { int exp; + int level; int attack; - unsigned int hp; - char name[]; + int defense; + int speed; + int hp; } Pokemon; + +void upgrade(*Pokemon p, int gainedExp) { + p->exp += gainedExp; + if (p->exp >= 4000) { + p->exp -= 4000; + p->level += 1; + } +} ``` - +In C++ we use classes: ```C++ -class Pokemon() { +class Pokemon { +public: // visibility modifier + int exp; + int level; + int attack; + int defense; + int speed; + int hp; + void upgrade(int gainedExp) { + exp += gainedExp; + if (exp >= 4000) { + exp -= 4000; + level += 1; + } + } } ``` \ No newline at end of file