Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package exo2;
- public class Temps {
- long heures;
- int minutes, secondes;
- public Temps() { }
- public Temps(long heures, int minutes, int secondes) {
- this.heures = heures;
- this.minutes = minutes;
- this.secondes = secondes;
- }
- public Temps(long t){
- secondes = (int) (t % 60);
- minutes = (int) ((t / 60) % 60);
- heures = t / 3600;
- }
- public long getHeures() {
- return heures;
- }
- public int getMinutes() {
- return minutes;
- }
- public int getSecondes() {
- return secondes;
- }
- public void setHeures(long heures) {
- this.heures = this.heures + heures;
- normaliser();
- }
- public void setMinutes(int minutes) {
- this.minutes = this.minutes + minutes;
- normaliser();
- }
- public void setSecondes(int secondes) {
- this.secondes = this.secondes + secondes;
- normaliser();
- }
- private long conversion(){
- return secondes + 60 * minutes + 3600 * heures;
- }
- private void normaliser(){
- secondes = (int) (conversion() % 60);
- minutes = (int) ((conversion() / 60) % 60);
- heures = conversion() / 3600;
- }
- public void ajouterTemps(long t){
- t = t + conversion();
- secondes = (int) (t % 60);
- minutes = (int) ((t / 60) % 60);
- heures = t / 3600;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement