Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package babycare;
- import java.util.*;
- public class Bebe extends Thread {
- private int matricula=0;
- private String nombre="";
- private String sexo="";
- public Bebe() {
- }
- public Bebe(int matricula){
- this.matricula=matricula;
- this.nombre="";
- this.sexo="";
- }
- public Bebe(int matricula, String nombre, String sexo) {
- this.matricula = matricula;
- this.nombre = nombre;
- this.sexo = sexo;
- }
- @Override
- public void run(){
- this.aleatoriaactividad();
- }
- public void dormir(){
- System.out.println("Bebe "+this.matricula+" esta durmiendo");
- try{
- Thread.sleep(5000);
- }
- catch (InterruptedException e ) {
- Thread.currentThread().interrupt();
- }
- System.out.println("Bebe "+this.matricula+" ya no esta durmiendo");
- }
- public void comer(){
- System.out.println("Bebe "+this.matricula+" esta Comiendo");
- try{
- Thread.sleep(3500);
- }
- catch (InterruptedException e ) {
- Thread.currentThread().interrupt();
- }
- System.out.println("Bebe "+this.matricula+" dejo de Comer");
- }
- public void cambiarpanal(){
- System.out.println("Bebe "+this.matricula+" estan cambiandole pañal");
- try{
- Thread.sleep(2000);
- }
- catch (InterruptedException e ) {
- Thread.currentThread().interrupt();
- }
- System.out.println("Bebe "+this.matricula+" tienen uevo pañal");
- }
- public int aleatoriaactividad (){
- int i = (int) (Math.random() * 3) + 1;
- haceractividad(i);
- return i;
- }
- public void haceractividad(int i){
- if (i==1){
- dormir();
- }
- else{
- if (i==2){
- comer();
- }
- else{
- if(i==3){
- cambiarpanal();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement