Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Hex {
- constructor(num) {
- this.value = num;
- }
- valueOf() {
- return this.value;
- }
- toString() {
- return '0x' + this.value.toString(16).toUpperCase();
- }
- plus(newObjorNum) {
- if (typeof newObjorNum === 'number') {
- return new Hex(newObjorNum + this.value);
- }
- return new Hex(newObjorNum.valueOf() + this.value);
- }
- minus(newObjorNum) {
- if (typeof newObjorNum === 'number') {
- return new Hex(this.value - newObjorNum);
- }
- return new Hex(this.value - newObjorNum.valueOf());
- }
- parse(str) {
- return parseInt(str, 16);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement