Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- @author Karen Alduncin
- */
- import java.util.*;
- import java.util.Random;
- import java.lang.Double;
- public class Ventilador
- {
- private double temp;
- private double tempinterior;
- private int personas;
- private String estado = "APAGADO";//"ENCENDIDO"
- private String nivel = "NA";//"BAJO","MEDIO","ALTO","TURBO"
- public static final double tempcorporal = 37.00;
- public Ventilador(double tp,double ti,int p)
- {
- temp =tp;
- estado =(tp>26)?"ENCENDIDO":estado;
- tempinterior =(ti==0.0)? tp + ((Ventilador.tempcorporal / tp ) * p):ti;
- nivel="BAJO";
- personas =p;
- }
- public Ventilador(double tp, int p)
- {
- new Ventilador(tp,0.0,p);
- }
- public void cambiarexterior()
- {
- Random r = new Random();
- double d = r.nextDouble();
- if(temp<48)
- temp = (d > 0.3)? temp +(10*r.nextDouble()): temp - (10*r.nextDouble());
- else
- temp = temp - (10*r.nextDouble());
- }
- public void ajustar()
- {
- Random r = new Random();
- double d = r.nextDouble();
- estado =(temp>26)?"ENCENDIDO":"APAGADO";
- // System.out.println(toString());
- if(temp>26&&temp<30||personas==1)
- {
- nivel="BAJO";
- tempinterior=(r.nextDouble() *24 + 20);
- }
- else
- {
- if(temp>26&&temp<35||personas==2)
- {
- nivel="MEDIO";
- tempinterior=19;
- }
- else
- if(temp>26&&temp<40||personas==3)
- {
- nivel="ALTO";
- tempinterior=18;
- }
- }
- if(temp>40||personas>3)
- {
- nivel="TURBO";
- tempinterior=(r.nextDouble() *17 + 15);
- }
- }
- public String toString()
- {
- return "\n" + estado + "\nNivel="+ nivel +"\nTemperatura EXTERIOR = " + temp + "\nPERSONAS = " + personas + "\nTemperatura INTERIOR = " + tempinterior;
- }
- public static void main(String[] args)
- {
- Ventilador abanico = (args.length>2)? new Ventilador(Double.parseDouble(args[0]), Double.parseDouble(args[1]),Integer.parseInt(args[2])):
- new Ventilador(Double.parseDouble(args[0]),Integer.parseInt(args[1]));
- System.out.println("ABANICO : "+abanico.toString());
- if(Double.parseDouble(args[0])>26.0)
- {
- for(int i=0;i<=3;i++){
- abanico.cambiarexterior();
- abanico.ajustar();
- System.out.println(abanico.toString());
- }
- }else
- System.out.println("la temperatura es menor a 26 grados se mantendra el abanico en nivel bajo");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement