Write the complete equals method (including the method header) for the Appliance class. Two appliance objects are logically equivalent if they have the same description (ignoring capitalization), id (ignoring capitalization), and price. As an example, the two appliances with this data would be considered equal: "dishwasher", "ABC123", 999 "DISHWASHER", "abc123", 999   Here is the appliance class: public class Appliance {          private String description;     private String id;     private int price; // using an int for simplicity          public Appliance(String description, String id, int price) {         this.description = description;         this.id = id;         this.price = price;     }     public String getDescription() {         return description;     }     public void setDescription(String description) {         this.description = description;     }     public String getId() {         return id;     }     public void setId(String id) {         this.id = id;     }     public int getPrice() {         return price;     }     public void setPrice(int price) {         if(price > 0) {             this.price = price;         }     }          @Override     public String toString() {         return description +                  "\n\tID: " + id + "\tPrice: $" + price;     }           }

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

Write the complete equals method (including the method header) for the Appliance class. Two appliance objects are logically equivalent if they have the same description (ignoring capitalization), id (ignoring capitalization), and price.

As an example, the two appliances with this data would be considered equal:

"dishwasher", "ABC123", 999

"DISHWASHER", "abc123", 999

 

Here is the appliance class:


public class Appliance {
    
    private String description;
    private String id;
    private int price; // using an int for simplicity
    
    public Appliance(String description, String id, int price) {
        this.description = description;
        this.id = id;
        this.price = price;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public int getPrice() {
        return price;
    }
    public void setPrice(int price) {
        if(price > 0) {
            this.price = price;
        }
    }
    
    @Override
    public String toString() {
        return description + 
                "\n\tID: " + id + "\tPrice: $" + price;
    }
    
    

}

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,