/* Incrementation sur une classe temps */ public class IncrementationTemps { /* Type agrege de stockage des informations */ /* relatives a un temps code sous la forme */ /* heure, minute, seconde */ static class Temps { int h = 0; int mn = 0; int s = 0; }; /* Programme principal */ public static void main(String [] args) { Temps t = new Temps(); int nbs; Ecran.afficherln("SVP, t (h, mn & s)?"); t.h = Clavier.saisirInt(); t.mn = Clavier.saisirInt(); t.s = Clavier.saisirInt(); Ecran.afficherln("SVP, Increment?"); nbs = Clavier.saisirInt(); t.s = t.s+nbs; if ( t.s >= 60 ) { t.mn = t.mn+(t.s/60); t.s = t.s%60; if ( t.mn >= 60 ) { t.h = (t.h+(t.mn/60))%24; t.mn = t.mn%60; } } Ecran.afficherln(t.h,":",t.mn,":",t.s); } }