Question: class InventoryItem { private String _name; private int _howMany; private double _cost; public InventoryItem ( String name, int howMany, double cost) { _name = name;

class InventoryItem { private String _name; private int _howMany; private double _cost; public InventoryItem ( String name, int howMany, double cost) { _name = name; _howMany = howMany; _cost = cost; } public String getName() { return _name; } public int gethowMany() { return _howMany; } public double getCost() { return _cost; } public String toString() { String s = "Name: " + _name + " Cost: " + _cost + " Quantity: " + _howMany + " "; return s; } public boolean equals(Object o) { InventoryItem ii = (InventoryItem) o; String name = ii.getName(); int howMany = ii.gethowMany(); double cost = ii.getCost(); InventoryItem temp = new InventoryItem(name, howMany, cost); if (temp._name == name) { return true; } else return false; } }

my equals method isnt working correctly, from the instructions must use signature equals method but it will be necessary to conver the Object to an InventoryItem instance for the comparison...

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!