Question: (b) Consider the class below that represents Voucher with two attributes: amount and store. Your task is to write the an equals() method, that

(b) Consider the class below that represents Voucher with two attributes: amount and store. Your task is to

(b) Consider the class below that represents Voucher with two attributes: amount and store. Your task is to write the an equals() method, that returns true if two instances of the Voucher have the same amount and store. public class Voucher { private int amount; private String store; public Voucher(int amount, String store) { this.amount amount; this.store store; } public int get Amount() { return amount; } public void setAmount(int amount) { this.amount = amount; } public String getStore() { return store; } public void setStore(String store) { this.store store; } (6 marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The equals method is typically overridden from the Object class to define how two instances of a custom class should be compared for equality The meth... View full answer

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 Programming Questions!