Zum Inhalt springen

BiMa13

Mitglieder
  • Gesamte Inhalte

    6
  • Benutzer seit

  • Letzter Besuch

  1. Hallo zusammen, bin fertig geworden und es funktioniert. Vielen Dank für Eure Hilfe! MINS = 60 SEC = 60 def clock(modus, hour_a, min_a, sec_a, hour, min, sec) check_pre(( hour_a.nat? and min_a.nat? and sec_a.nat? and hour.nat? and min.nat? and sec.nat? and modus.nat? and (modus == 24 or modus == 12) and (hour_a >= 0) and (min_a >= 0) and (sec_a >= 0) and (hour >= 0) and (min >= 0) and (sec >= 0) and (hour_a < modus) and (min_a < 60) and (sec_a < 60) and (hour < modus) and (min < 60) and (sec < 60))) #Zeit in Sekunden umwandeln time_in_sec_a = time_to_sec(hour_a, min_a, sec_a) time_in_sec = time_to_sec(hour, min, sec) #Zeiten mit einander Addieren time_in_sec_sum = time_in_sec_a + time_in_sec #Array berechnen [new_time_hour(time_all(modus, time_in_sec_sum)), new_time_min(time_all(modus, time_in_sec_sum)), new_time_sec(time_all(modus, time_in_sec_sum))] end #Methode zum Zeit in Sekunden wandeln def time_to_sec(hour, min, sec) (((hour * MINS ) + min ) * SEC) + sec end #Maximale sekunden anzahl def time_all(modus, sec_all) sec_all % (modus * MINS * SEC) end #Neue Anzahl von Stunden def new_time_hour(sec_all) sec_all / (MINS * SEC) end #Neue Anzahl von Minuten def new_time_min(sec_all) (sec_all % (MINS * SEC)) / SEC end #Neue Anzahl von Sekunden def new_time_sec(sec_all) (sec_all % (MINS * SEC)) % SEC end
  2. Suche nur Hilfe. Wenn du nicht helfen willst, musst du auch nicht antworten.
  3. Wie gesagt, komme ja an dieser Stelle einfach nicht weiter. Vielleicht könntest du mir einen Lösungsvorschlag anbieten:old
  4. def_class(:Clock24,[:hour24,:min,:sec]) { def invariant? () self.hour24.hour24? and self.min.min? and self.sec.sec? end } def_class(:ClockSec,[:day_sec]) { def invariant?() self.day_sec.day_sec? end } Bin jetzt soweit, scheint aber nicht ganz richtig zu sein...:upps
  5. Wir programmieren in Ruby und mir fehlt irgendwie der Anfang. Bräuchte eine Starthilfe. Danke
  6. Hallo, habe eine Aufgabe in der Uni bekommen und komme nicht weiter. Vielleicht kann mir einer helfen. Danke! Uhrenarithmetik Schreiben Sie eine Funktion mit der man eine übliche Digitaluhranzeige (Stunden, Minuten, Sekunde) um einen Zeitbetrag (Stunden, Minuten, Sekunden) vorstellen kann. Die Uhranzeige soll 24 Stunden haben. Das Resultat soll ein Array der Größe 3 sein ([hour,min,sec] z.B. [12,30,10]).

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...