/* Manipulations sur une classe temps */ public class ManipulationTemps { /* 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 t1 = new Temps(); Temps t2 = new Temps(); boolean inferieurEgalT1T2; int difference; int s1; int s2; Ecran.afficherln("SVP, t1 (h, mn & s)?"); t1.h = Clavier.saisirInt(); t1.mn = Clavier.saisirInt(); t1.s = Clavier.saisirInt(); Ecran.afficherln("SVP, t2 (h, mn & s)?"); t2.h = Clavier.saisirInt(); t2.mn = Clavier.saisirInt(); t2.s = Clavier.saisirInt(); s1 = 3600*t1.h+60*t1.mn+t1.s; s2 = 3600*t2.h+60*t2.mn+t2.s; inferieurEgalT1T2 = (s1 <= s2); if ( inferieurEgalT1T2 ) { difference = s2-s1; Ecran.afficherln("[",t2.h,":",t2.mn,":",t2.s,"]"); Ecran.afficherln("[",t1.h,":",t1.mn,":",t1.s,"]"); } else { difference = s1-s2; Ecran.afficherln("[",t1.h,":",t1.mn,":",t1.s,"]"); Ecran.afficherln("[",t2.h,":",t2.mn,":",t2.s,"]"); } Ecran.afficherln("Ecart : ",s2-s1," secondes"); } }