import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
public static class BlogTitle {
private String title;
public BlogTitle(String title){
this.title=title;
}
public String getTitle(){
return this.title;
}
public String getSlug(){
String s=this.getTitle().toLowerCase().replace(" ","-");
char[] t= s.toCharArray();
s="";
for (char c : t) {
if (c >= 'a' && c <= 'z' || c == '-')
s += c;
}
return s;
}
@Override
public boolean equals(Object o){
if(o instanceof BlogTitle){
return this.getSlug().equals(((BlogTitle) o).getSlug());
}
return false;
}
@Override
public int hashCode(){
return this.getSlug().hashCode();
}
}
public static void main(String[] args) {
BlogTitle blogTitle = new BlogTitle("This is my.... ARTICLE!!!");
System.err.println(blogTitle.getSlug());
System.out.println(blogTitle.equals(new String[0]));
System.out.println(blogTitle.equals(new BlogTitle("test")));
System.out.println(blogTitle.equals(new BlogTitle("This is my.... ARTICLE!!!")));
System.out.println(blogTitle.equals(new BlogTitle("this-is-my-article")));
System.out.println(blogTitle.hashCode());
System.out.println(new BlogTitle("this is my article").hashCode());
System.out.println(new BlogTitle("a").hashCode());
System.out.println(new BlogTitle("b").hashCode());
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: