Beispiel #1
0
  public int compareTo(Contents that) {
    if (_name.compareTo(that.name()) > 0) {
      return 1;
    }
    if (_name.compareTo(that.name()) < 0) {
      return -1;
    }
    if (_build.compareTo(that.build()) > 0) {
      return 1;
    }
    if (_build.compareTo(that.build()) < 0) {
      return -1;
    }
    if (_specs.compareTo(that.specs()) > 0) {
      return 1;
    }
    if (_specs.compareTo(that.specs()) < 0) {
      return -1;
    }

    if (cost() - that.cost() != 0) {
      return cost() - that.cost();
    }

    return 0;
  }
Beispiel #2
0
 @Override
 public int hashCode() {
   if (hashCode == 0) {
     int result = 17;
     result = 37 * result + _name.hashCode();
     result = 37 * result + _build.hashCode();
     result = 37 * result + _specs.hashCode();
     result = 37 * result + _stuff.hashCode();
     hashCode = result;
   }
   return hashCode;
 }
Beispiel #3
0
 public String printComponents() {
   return "Package Name: "
       + _name
       + "\n=====================================\n"
       + _build.printComponents()
       + "\n=====================================\n"
       + _specs.printComponents()
       + "\n=====================================\n"
       + "Accessories: "
       + " \n====================================\n"
       + _stuff.toString()
       + " \n====================================\n"
       + " Final Price: $"
       + cost();
 }
Beispiel #4
0
  @Override
  public boolean equals(Object thatObject) {
    if (!(thatObject instanceof contObj)) {
      return false;
    }
    if (thatObject == this) {
      return true;
    }

    contObj newSpecsObj = (contObj) thatObject;

    return _name.equals(newSpecsObj.name())
        && _build.equals(newSpecsObj.build())
        && _specs.equals(newSpecsObj.specs())
        && _stuff.equals(newSpecsObj.compList());
  }
Beispiel #5
0
 public int cost() {
   return _build.totPrice() + _specs.price() + stuffCost();
 }