create a class word representing a word two words


Create a class Word, representing a word. Two words should be considered equal if they consist of the same sequence of letters and we consider upper case and lower case as equal. For example hello, Hello and HELLO are considered to be equal. The methods equals and hashCode de ne the meaning of \equality". Thus, the class Word should look like the following.

public class Word implements Comparable {
private String word;
public Word(String str) { ... }
public String toString() { return word; }
/* Override Object methods */
public int hashCode() { "compute a hash value for word" }
public boolean equals(Object other) { "true if two words are equal" }
/* Implement Comparable */
public int compareTo(Word w) { "compares two words lexicographically"}
}
Note:
 If you want, you can add more methods. The methods mentioned above are the minimum requirement.
 Task 6 and onward is based on task 5. Thus, carefully test all methods before proceeding.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: create a class word representing a word two words
Reference No:- TGS0211075

Expected delivery within 24 Hours