Correct mistakes
This commit is contained in:
parent
7afc27e1cd
commit
767346f408
5 changed files with 73 additions and 6 deletions
40
.vscode/launch.json
vendored
40
.vscode/launch.json
vendored
|
|
@ -19,6 +19,46 @@
|
||||||
"target": "m323",
|
"target": "m323",
|
||||||
"configuration": "release",
|
"configuration": "release",
|
||||||
"preLaunchTask": "swift: Build Release m323"
|
"preLaunchTask": "swift: Build Release m323"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "swift",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder:m323}",
|
||||||
|
"name": "Debug WeDontLikeCharA",
|
||||||
|
"target": "WeDontLikeCharA",
|
||||||
|
"configuration": "debug",
|
||||||
|
"preLaunchTask": "swift: Build Debug WeDontLikeCharA"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "swift",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder:m323}",
|
||||||
|
"name": "Release WeDontLikeCharA",
|
||||||
|
"target": "WeDontLikeCharA",
|
||||||
|
"configuration": "release",
|
||||||
|
"preLaunchTask": "swift: Build Release WeDontLikeCharA"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "swift",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder:m323}",
|
||||||
|
"name": "Debug Aufgabe3",
|
||||||
|
"target": "Aufgabe3",
|
||||||
|
"configuration": "debug",
|
||||||
|
"preLaunchTask": "swift: Build Debug Aufgabe3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "swift",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder:m323}",
|
||||||
|
"name": "Release Aufgabe3",
|
||||||
|
"target": "Aufgabe3",
|
||||||
|
"configuration": "release",
|
||||||
|
"preLaunchTask": "swift: Build Release Aufgabe3"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,8 @@ print(calculateAverage(items: items))
|
||||||
// 3.3
|
// 3.3
|
||||||
|
|
||||||
func sortListAlphabetical(items: [String]) -> [String] {
|
func sortListAlphabetical(items: [String]) -> [String] {
|
||||||
return items.sorted()
|
let itemsCopy = items
|
||||||
|
return itemsCopy.sorted()
|
||||||
}
|
}
|
||||||
|
|
||||||
let stringItems = ["ABC", "CDF", "BDC"]
|
let stringItems = ["ABC", "CDF", "BDC"]
|
||||||
|
|
@ -45,7 +46,9 @@ struct ComplexType {
|
||||||
}
|
}
|
||||||
|
|
||||||
func sortComplexType(items: [ComplexType]) -> [ComplexType] {
|
func sortComplexType(items: [ComplexType]) -> [ComplexType] {
|
||||||
return items.sorted {
|
let itemsCopy = items
|
||||||
|
|
||||||
|
return itemsCopy.sorted {
|
||||||
($0.date, $0.priority, $0.title) < ($1.date, $1.priority, $1.title)
|
($0.date, $0.priority, $0.title) < ($1.date, $1.priority, $1.title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
| ------- | -------------------- | ------------------------------------------------ | ----------------------------------- | ---------------- |
|
| ------- | -------------------- | ------------------------------------------------ | ----------------------------------- | ---------------- |
|
||||||
| 1.1 | Ja | Nein | Nein | impure |
|
| 1.1 | Ja | Nein | Nein | impure |
|
||||||
| 1.2 | Ja | Ja | Ja | pure |
|
| 1.2 | Ja | Ja | Ja | pure |
|
||||||
| 1.3 | Ja | ja | Ja | pure |
|
| 1.3 | Ja | ja | Ja | impure |
|
||||||
| 1.4 | Ja | Nein | Ja | impure |
|
| 1.4 | Ja | Nein | Ja | impure |
|
||||||
| 1.5 | Ja | Ja | Ja | pure |
|
| 1.5 | Ja | Ja | Ja | impure |
|
||||||
| 1.6 | Ja | Ja | Nein | impure |
|
| 1.6 | Ja | Ja | Nein | impure |
|
||||||
|
|
||||||
## Aufgabe 1.1
|
## Aufgabe 1.1
|
||||||
|
|
@ -40,7 +40,11 @@ console.log(add(2, 4)); // Ausgabe: 6
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function firstCharacter(str) {
|
function firstCharacter(str) {
|
||||||
|
if (!len(str) > 0) {
|
||||||
return str.charAt(0);
|
return str.charAt(0);
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(firstCharacter("Hello")); // Ausgabe: H
|
console.log(firstCharacter("Hello")); // Ausgabe: H
|
||||||
|
|
@ -64,7 +68,11 @@ console.log(multiplyWithRandom(10, Math.random())); // Ausgabe: Eine zufällige
|
||||||
```js
|
```js
|
||||||
// Funktion zum Teilen einer Zahl durch eine andere
|
// Funktion zum Teilen einer Zahl durch eine andere
|
||||||
function divideNumbers(dividend, divisor) {
|
function divideNumbers(dividend, divisor) {
|
||||||
|
if (dividen != 0 && divisor != 0) {
|
||||||
return dividend / divisor;
|
return dividend / divisor;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(divideNumbers(10, 2)); // Ausgabe: 5
|
console.log(divideNumbers(10, 2)); // Ausgabe: 5
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,16 @@ let package = Package(
|
||||||
.executableTarget(
|
.executableTarget(
|
||||||
name: "m323"
|
name: "m323"
|
||||||
),
|
),
|
||||||
|
.executableTarget(
|
||||||
|
name: "WeDontLikeCharA",
|
||||||
|
path: "02",
|
||||||
|
sources: ["WeDontLikeCharA.swift"]
|
||||||
|
),
|
||||||
|
.executableTarget(
|
||||||
|
name: "Aufgabe3",
|
||||||
|
path: "03",
|
||||||
|
sources: ["Aufgabe3.swift"]
|
||||||
|
),
|
||||||
.testTarget(
|
.testTarget(
|
||||||
name: "m323Tests",
|
name: "m323Tests",
|
||||||
dependencies: ["m323"]
|
dependencies: ["m323"]
|
||||||
|
|
|
||||||
6
Tests/m323Tests/m323Tests.swift
Normal file
6
Tests/m323Tests/m323Tests.swift
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import Testing
|
||||||
|
@testable import m323
|
||||||
|
|
||||||
|
@Test func example() async throws {
|
||||||
|
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue