Question: PART A: (using JAVA) You are given the incomplete Java codes for the classes Item and Shop. Read the codes you are given carefully, and
PART A: (using JAVA)
You are given the incomplete Java codes for the classes Item and Shop. Read the codes you are given carefully, and then answer the following questions:
- In the class Item, write the method equals: the method takes as input an Object other, if the other Object is an Item and the name of the other is equal to the name of the calling object, the method return true. Otherwise, the method returns false.
// Write your code in the class
- In the class Shop, write the method HasItem: the method takes as input an Item itm. It returns -1 if the given Item (itm) is not found in the array (items). It returns the index of its position if it is found in the array.
// Write your code in the class
- In the class Shop, write the method addItem: the method takes as input an Item itm. If the Item is not in the array items, it adds the item to the array items and returns true. Otherwise, it returns false.
// Write your code in the class
PART B:
- Which methods from the code are overriding? Explain why. (10 points)
- Which method from the code uses polymorphism? Explain why. (10 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
