Advertisement
Guest User

Codes

a guest
Feb 21st, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. public class Converter {
  2.  
  3.     private Double value;
  4.     private String from;
  5.     private String to;
  6.  
  7.     /**
  8.      * @param value
  9.      * @param metric
  10.      */
  11.     public Converter(Double value, String from, String to) {
  12.         this.value = value;
  13.         this.from = from;
  14.         this.to = to;
  15.     }
  16.  
  17.     /**
  18.      * @return Double
  19.      * @throws Exception must provide data.
  20.      */
  21.     public Double convert() throws Exception {
  22.         switch (this.from) {
  23.             case "in":
  24.                 switch (this.to) {
  25.                     case "cm":
  26.                         return this.value * 2.54;
  27.                 }
  28.             default:
  29.                 throw new Exception("You didn't provide me with shit fucktard.");
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement