megi_al

Untitled

Jun 21st, 2021
891
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Hex {
  2.     constructor(number) {
  3.         this.value = Number(number);
  4.     }
  5.  
  6.     valueOf(){
  7.         return this.value;
  8.     }
  9.     toString(){
  10.         return `0x${(this.value.toString(16)).toUpperCase()}`;
  11.     }
  12.  
  13.     plus(number) {
  14.         let result = (this.value  + Number(number.valueOf()));
  15.         return new Hex(result);
  16.     }
  17.  
  18.     minus(number) {
  19.         let result = (this.value - Number(number.valueOf()));
  20.         return new Hex(result);
  21.     }
  22.  
  23.     parse(text){
  24.         return parseInt(text, 16);
  25.     }
  26. }
  27.  
RAW Paste Data