- Rename "Aufgabe 5"->Aufgabe5 and "Aufgabe 6"->Aufgabe6; spaces broke bazel run (Aspect URL-encoding, scala/JVM launcher self-path). - Per-directory BUILD.bazel: Aufgabe5 (swift_binary), Aufgabe6 (swift_binary). - Aufgabe6/Third: Scala app via rules_scala (scala_library + scala_binary). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
29 lines
1.1 KiB
Swift
29 lines
1.1 KiB
Swift
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)
|
|
}
|