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 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
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
Get step-by-step solutions from verified subject matter experts
