diff --git a/3d Prototyp/Assets/Scripts/Utility/DayOfWeekExtension.cs b/3d Prototyp/Assets/Scripts/Utility/DayOfWeekExtension.cs new file mode 100644 index 00000000..5e0ede3f --- /dev/null +++ b/3d Prototyp/Assets/Scripts/Utility/DayOfWeekExtension.cs @@ -0,0 +1,35 @@ +using System; + +namespace Utility +{ + public static class DayOfWeekExtension + { + /// + /// Gibt den Wochentag zurück, der auf den gegebenen Wochentag folgt. + /// + public static DayOfWeek GetNext(this DayOfWeek current) => GetFutureDay(current, 1); + + /// + /// Gibt den Wochentag zurück, der in der gegebenen Anzahl an Tagen auf den gegebenen Wochentag folgt. + /// + /// Der aktuelle Wochentag. + /// Die Anzahl an Tagen, die vergehen sollen. + public static DayOfWeek GetFutureDay(this DayOfWeek current, int days) => + (DayOfWeek)(((int)current + days) % 7); + + /// + /// Gibt den deutschen Namen des Wochentags zurück. + /// + public static string GetName(this DayOfWeek weekday) => weekday switch + { + DayOfWeek.Monday => "Montag", + DayOfWeek.Tuesday => "Dienstag", + DayOfWeek.Wednesday => "Mittwoch", + DayOfWeek.Thursday => "Donnerstag", + DayOfWeek.Friday => "Freitag", + DayOfWeek.Saturday => "Samstag", + DayOfWeek.Sunday => "Sonntag", + _ => "Unbekannt" + }; + } +} diff --git a/3d Prototyp/Assets/Scripts/Utility/Weekday.cs.meta b/3d Prototyp/Assets/Scripts/Utility/DayOfWeekExtension.cs.meta similarity index 100% rename from 3d Prototyp/Assets/Scripts/Utility/Weekday.cs.meta rename to 3d Prototyp/Assets/Scripts/Utility/DayOfWeekExtension.cs.meta diff --git a/3d Prototyp/Assets/Scripts/Utility/Weekday.cs b/3d Prototyp/Assets/Scripts/Utility/Weekday.cs deleted file mode 100644 index 0692f803..00000000 --- a/3d Prototyp/Assets/Scripts/Utility/Weekday.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; - -namespace Utility -{ - public enum Weekday - { - Monday = 0, - Tuesday = 1, - Wednesday = 2, - Thursday = 3, - Friday = 4, - Saturday = 5, - Sunday = 6 - } - - public static class WeekdayExtension - { - /// - /// Gibt den Wochentag zurück, der auf den gegebenen Wochentag folgt. - /// - public static Weekday GetNext(this Weekday current) => GetFutureDay(current, 1); - - /// - /// Gibt den Wochentag zurück, der in der gegebenen Anzahl an Tagen auf den gegebenen Wochentag folgt. - /// - /// Der aktuelle Wochentag. - /// Die Anzahl an Tagen, die vergehen sollen. - public static Weekday GetFutureDay(this Weekday current, int days) => - (Weekday)(((int)current + days) % 7); - - /// - /// Gibt den deutschen Namen des Wochentags zurück. - /// - public static string GetName(this Weekday weekday) => weekday switch - { - Weekday.Monday => "Montag", - Weekday.Tuesday => "Dienstag", - Weekday.Wednesday => "Mittwoch", - Weekday.Thursday => "Donnerstag", - Weekday.Friday => "Freitag", - Weekday.Saturday => "Samstag", - Weekday.Sunday => "Sonntag", - _ => "Unbekannt" - }; - } - - public static class DayOfWeekExtension - { - /// - /// Gibt den Wochentag zurück, der auf den gegebenen Wochentag folgt. - /// - public static DayOfWeek GetNext(this DayOfWeek current) => GetFutureDay(current, 1); - - /// - /// Gibt den Wochentag zurück, der in der gegebenen Anzahl an Tagen auf den gegebenen Wochentag folgt. - /// - /// Der aktuelle Wochentag. - /// Die Anzahl an Tagen, die vergehen sollen. - public static DayOfWeek GetFutureDay(this DayOfWeek current, int days) => - (DayOfWeek)(((int)current + days) % 7); - - /// - /// Gibt den deutschen Namen des Wochentags zurück. - /// - public static string GetName(this DayOfWeek weekday) => weekday switch - { - DayOfWeek.Monday => "Montag", - DayOfWeek.Tuesday => "Dienstag", - DayOfWeek.Wednesday => "Mittwoch", - DayOfWeek.Thursday => "Donnerstag", - DayOfWeek.Friday => "Freitag", - DayOfWeek.Saturday => "Samstag", - DayOfWeek.Sunday => "Sonntag", - _ => "Unbekannt" - }; - } -} \ No newline at end of file diff --git a/3d Prototyp/Assets/Zeitschaltuhr.cs b/3d Prototyp/Assets/Zeitschaltuhr.cs index 05fc2f0a..2a7aed0f 100644 --- a/3d Prototyp/Assets/Zeitschaltuhr.cs +++ b/3d Prototyp/Assets/Zeitschaltuhr.cs @@ -4,6 +4,9 @@ using System.Collections.Generic; using UnityEngine; using Utility; +/// +/// Macht genau das was man erwartet: Schaltet je nach Uhrzeit alle Kinder an oder aus. +/// public class Zeitschaltuhr : MonoBehaviour, ISerializationCallbackReceiver { private TimeSpan _turnOnTimeSpan;