TAAFT
Free mode
100% free
Freemium
Free Trial
Deals
Create tool
  • Code Humanizer
    Transform AI code into human-like programming
    Open
    2,697
    849
    3.4
    1,137
    Released 3mo ago
    100% Free
    package eecs2030.lab3; import java.util.Objects; public final class Bird implements Comparable<Bird> { private final String species; private final double weightInGrams; public Bird(String species, double weightInGrams) { this.species = species; this.weightInGrams = weightInGrams; } public Bird() { this("Unknown", 300.0); } public String getSpecies() { return species; } public double getWeightInGrams() { return weightInGrams; } private double weightRoundedTo20Grams() { return Math.round(weightInGrams / 20.0) * 20.0; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof Bird)) return false; Bird other = (Bird) obj; return Objects.equals(species, other.species) && Double.compare(weightRoundedTo20Grams(), other.weightRoundedTo20Grams()) == 0; } @Override public int hashCode() { long rBits = Double.doubleToLongBits(weightRoundedTo20Grams()); int weightHash = (int) (rBits ^ (rBits >>> 32)); return Objects.hash(species, weightHash); } @Override public String toString() { return String.format("Bird[species=%s, weightInGrams=%.3f]", species, weightInGrams); } @Override public int compareTo(Bird other) { double thisRounded = weightRoundedTo20Grams(); double otherRounded = other.weightRoundedTo20Grams(); int cmp = Double.compare(thisRounded, otherRounded); return cmp != 0 ? cmp : species.compareTo(other.species); } }

Other tools

Post
0 AIs selected
Clear selection
#
Name
Task