add fifth one
This commit is contained in:
parent
34fa731bf6
commit
36f6abeea4
2 changed files with 39 additions and 0 deletions
10
Sources/Aufgabe 5/BUILD.bazel
Normal file
10
Sources/Aufgabe 5/BUILD.bazel
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
load("@rules_swift//swift:swift.bzl", "swift_binary")
|
||||||
|
|
||||||
|
# Per-directory BUILD: define targets where their sources live, then reference
|
||||||
|
# them by label (e.g. //Sources/Aufgabe 5:Aufgabe5) from elsewhere to keep the
|
||||||
|
# top-level BUILD.bazel uncluttered.
|
||||||
|
swift_binary(
|
||||||
|
name = "Aufgabe5",
|
||||||
|
srcs = ["main.swift"],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
29
Sources/Aufgabe 5/main.swift
Normal file
29
Sources/Aufgabe 5/main.swift
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
let weatherData: [(city: String, description: String, temperature: Double)] = [
|
||||||
|
(city: "Zurich", description: "cloudy", temperature: 18.5),
|
||||||
|
(city: "Bern", description: "sunny", temperature: 22.1),
|
||||||
|
(city: "Geneva", description: "rainy", temperature: 15.3),
|
||||||
|
(city: "Basel", description: "sunny", temperature: 24.7),
|
||||||
|
(city: "Lucerne", description: "foggy", temperature: 11.0),
|
||||||
|
(city: "Lugano", description: "sunny", temperature: 31.2),
|
||||||
|
(city: "Lausanne", description: "cloudy", temperature: 19.8),
|
||||||
|
(city: "Chur", description: "snowing", temperature: -2.5),
|
||||||
|
(city: "Davos", description: "snowing", temperature: -5.1),
|
||||||
|
(city: "Locarno", description: "thunderstorm", temperature: 27.4),
|
||||||
|
]
|
||||||
|
|
||||||
|
func weatherStation(city: String, description: String, temperature: Double) -> (
|
||||||
|
String, String, Double
|
||||||
|
)? {
|
||||||
|
if temperature >= 20 {
|
||||||
|
let dateTimeString = Date.now.formatted(date: .abbreviated, time: .shortened)
|
||||||
|
return (description, dateTimeString, temperature)
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for weather in weatherData {
|
||||||
|
weatherStation(city: weather.0, description: weather.1, temperature: weather.2)
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue