All files Treasure.ts

90.9% Statements 10/11
88.88% Branches 8/9
100% Functions 4/4
90.9% Lines 10/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36              1x       266789x       9969x       17874x 3089x   14785x     14785x 3932x   10853x       266549x      
/**
 * @author Timo lehnertz
 */
 
/**
 * Immutable Treasure class representing a treasure
 */
export class Treasure {
  public readonly id: number;
 
  public constructor(id: number) {
    this.id = id;
  }
 
  public equals(other: Treasure): boolean {
    return this.id === other.id;
  }
 
  public static compare(a: Treasure | null, b: Treasure | null): boolean {
    if (a === null && b !== null) {
      return false;
    }
    Iif (a !== null && b === null) {
      return false;
    }
    if (a !== null && b !== null) {
      return a.equals(b);
    }
    return true;
  }
 
  public static create(instance: Treasure): Treasure {
    return new Treasure(instance.id);
  }
}