Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. package ru.H4kt.SimpleFramework.utils;
  2.  
  3. public class ColorInteger {
  4.    
  5.     private double value = 0;
  6.    
  7.     public ColorInteger() {}
  8.    
  9.     public ColorInteger(int value) {
  10.         this.value = value;
  11.     }
  12.    
  13.     public void increase(double amount) {
  14.         value += amount;
  15.         this.checkBounds();
  16.     }
  17.    
  18.     public void decrease(double amount) {
  19.         value -= amount;
  20.         this.checkBounds();
  21.     }
  22.    
  23.     private void checkBounds() {
  24.         if (value>255) value = 255;
  25.         if (value<0) value = 0;
  26.     }
  27.    
  28.     public int increaseAndGet(double amount) {
  29.         this.increase(amount);
  30.         return Utils.round(value);
  31.     }
  32.    
  33.     public int decreaseAndGet(double amount) {
  34.         this.decrease(amount);
  35.         return Utils.round(value);
  36.     }
  37.    
  38.     public int get() {
  39.         return Utils.round(value);
  40.     }
  41.    
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement