ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Practica de Tiempo POO


Enviado por   •  24 de Septiembre de 2015  •  Prácticas o problemas  •  528 Palabras (3 Páginas)  •  102 Visitas

Página 1 de 3

package mypkg;

import java.util.Scanner;

public class TryTiempo {

    public static void main(String[] args) {

        Scanner dato=new Scanner(System.in);

        int hrs,min,sg;

      Tiempo tp1=new Tiempo();

      Tiempo hr=new Tiempo(0);

      Tiempo mts=new Tiempo(0);

      Tiempo seg=new Tiempo(0);

        System.out.println("Introduzca la hora");

        hrs=dato.nextInt();

        System.out.println("Introduzca los minutos");

        min=dato.nextInt();

        System.out.println("Introduzca los segundos:");

        sg=dato.nextInt();

        hr.setH(hrs);

        mts.setM(min);

        seg.setS(sg);

        System.out.println("0:0:0");

        System.out.println(hr.getH()+":00:00");

        System.out.println(hr.getH()+":"+mts.getM()+":00");

        System.out.println(hr.getH()+":"+mts.getM()+":"+seg.getS());

      }

}

package mypkg;

public class Tiempo {

    private int m;

    private int h;

    private int s;

public Tiempo(){

    this.m=0;

    this.h=0;

    this.s=0;

}

    Tiempo(int h) {

        this.m=0;

        this.h=h;

        this.s=0;

    }

    Tiempo(int h, int m, int s) {

        this.h=h;

        this.m=m;

        this.s=s;

    }

    public int getM() {

        return m;

    }

    public void setM(int m) {

        if(m<60)

            this.m=m;

        else

            this.m=0;

    }

    public int getH() {

        return h;

    }

    public void setH(int h) {

        if(h<=24)

            this.h=h;

        else

            this.h=0;

    }

    public int getS() {

        return s;

    }

    public void setS(int s) {

        if(s<60)

...

Descargar como (para miembros actualizados)  txt (1.8 Kb)   pdf (30.2 Kb)   docx (10.2 Kb)  
Leer 2 páginas más »
Disponible sólo en Clubensayos.com