Advertisement
Guest User

Codes

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