Advertisement
tutostudio1

MODELO - CONVERSOR DE TEMPERATURA

May 4th, 2015
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. package conversor;
  2.  
  3. public class Modelo {
  4.  
  5.     private double cel;
  6.     private double kel;
  7.     private double fah;
  8.  
  9.     public Modelo() {
  10.         cel = 0;
  11.         kel = 0;
  12.         fah = 0;
  13.     }
  14.  
  15.     public void celsius() {
  16.         kel = cel + 273.15;
  17.         fah = cel * 1.8 + 32;
  18.     }
  19.  
  20.     public void kelvin() {
  21.         cel = kel - 273.15;
  22.         fah = cel * 1.8 + 32;
  23.     }
  24.  
  25.     public void fahrenheit() {
  26.         cel = (fah - 32) / 1.8;
  27.         kel = cel + 273.15;
  28.     }
  29.  
  30.     //GET AND SETTERS
  31.     public double getCel() {
  32.         return cel;
  33.     }
  34.  
  35.     public void setCel(double cel) {
  36.         this.cel = cel;
  37.         celsius();
  38.     }
  39.  
  40.     public double getKel() {
  41.         return kel;
  42.     }
  43.  
  44.     public void setKel(double kel) {
  45.         this.kel = kel;
  46.         kelvin();
  47.     }
  48.  
  49.     public double getFah() {
  50.         return fah;
  51.     }
  52.  
  53.     public void setFah(double fah) {
  54.         this.fah = fah;
  55.         fahrenheit();
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement