public class Marker { private String color; private double ink = 15000; private final int INK_PER_CHAR = 1; private final double TOLERANCE = 0.001; public Marker() { } public Marker(String color) { this.color = color; } public Marker(double ink) { this.ink = ink; } public Marker(String color, int ink) { this.color = color; this.ink = ink; } public double write (String sentence) { return ink -= INK_PER_CHAR * sentence.length(); } public String getColor() { return color; } public void setColor(String color) { this.color = color; } public void setInk(double ink) { this.ink = ink; } public double getInk() { return ink; } public void refill() { setInk(15000); } public String toString() { return "Color is "+color+" amount of ink is "+ink ; } public boolean equals (Marker other) { return Math.abs(this.ink-other.getInk()) < TOLERANCE && this.color.equals(other.getColor()) ; } public int compareTo (Marker other) { if (Math.abs(this.ink - other.getInk()) < TOLERANCE) return 0; else return (int)(this.ink - other.getInk()) ; } }