From 9b741d90db682828a1aa298ce7e9e6fed7e80d05 Mon Sep 17 00:00:00 2001 From: law39 Date: Fri, 1 May 2020 14:40:53 +0100 Subject: [PATCH] Improved DictionaryEntry Equals method --- .../uk/ac/aber/cs221/group20/json/DictionaryEntry.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs221/group20/json/DictionaryEntry.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs221/group20/json/DictionaryEntry.java index a4295f0..34a1b69 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs221/group20/json/DictionaryEntry.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs221/group20/json/DictionaryEntry.java @@ -172,14 +172,10 @@ public class DictionaryEntry { * @param entry Object that the DictionaryEntry object is comparing itself to. * @return Returns true (if equal) or false (not equal). */ - @Override - public boolean equals(Object entry) { + public boolean equals(DictionaryEntry entry) { - // Cast the object to be a DictionaryEntry. - DictionaryEntry otherEntry = (DictionaryEntry) entry; - // Check it they're equal by looking if they have equal 'welsh' or 'english' with the same 'wordType'. - return ((this.getWelsh().equalsIgnoreCase(otherEntry.getWelsh()) || this.getEnglish().equalsIgnoreCase(otherEntry.getWelsh())) && - this.getWordType().equals(otherEntry.getWordType())); + return ((this.getWelsh().equalsIgnoreCase(entry.getWelsh()) || this.getEnglish().equalsIgnoreCase(entry.getWelsh())) && + this.getWordType().equals(entry.getWordType())); } }