Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. public class Radio extends HomeAppliances implements Runnable {
  2.  
  3.     public int channel;
  4.     public int volume;
  5.     public String type;
  6.    
  7.     public Radio(boolean isOn, double consumption, int voltage, int channel, int volume, String type, int id) {
  8.         super(isOn, consumption, voltage, id);
  9.         this.channel = channel;
  10.         this.volume = volume;
  11.         this.type = type;
  12.     }  
  13.    
  14.     @Override
  15.     public void run() {
  16.         synchronized(this) {
  17.             System.out.println("Rádio de ID: " + super.getId() + "; Ligado: " + super.isOn() + "; Consumo: " + super.getConsumption() + "; Voltagem: " + super.getVoltage() + "; Canal: " + getChannel() + "; Volume: " + getVolume() + "; Tipo: " + getType() + ";");        
  18.        
  19.             try {
  20.                 Thread.sleep(1000);
  21.             } catch(InterruptedException exception) {
  22.                 System.out.println("Thread interrompida.");
  23.             }
  24.         }
  25.     }
  26.  
  27.     public int getChannel() {
  28.         return channel;
  29.     }
  30.  
  31.     public int getVolume() {
  32.         return volume;
  33.     }
  34.  
  35.     public String getType() {
  36.         return type;
  37.     }
  38.    
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement