Advertisement
pkopy

Untitled

Apr 21st, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. package enues;
  2.  
  3. public enum Units {
  4.     METER('M'), KILOGRAM('K'), QTY('Q');
  5.  
  6.     private char value;
  7.  
  8.     Units(char value) {
  9.         this.value = value;
  10.     }
  11.  
  12.     public int getValue() {
  13.         return value;
  14.     }
  15. }
  16.  
  17. public class Shop {
  18.     public static void main(String[] args) {
  19.         Units unit = Units.METER;
  20.         String name = "Coś";
  21.  
  22.         if(unit == Units.METER) {
  23.             System.out.println(name + " "  + Character.toString((char) unit.getValue()));
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement