Your Ad Here

Your are Visitor

About This Blog

You will find everything from new and unique gadgets to software code, PC tweaks, How tos, etc in this blog.

Monday, December 8, 2008

The Poets(Rhymers) helper.

WordMatcher I made 3 years ago, simple program for those that are very new to computer science. Its pretty useful if your a poet or you write rhymes.

IF YOUR ON A PC RUNNING WINDOWS you must have java Runtime and java SDK to run this program.
Get em here
Otherwise if your running any form of linux you should be good to go.

Dictionary Code below.
words.txt

WordMatcher.java code below.
Copy The source below or download it from the link below.
WordMatcher.java

Download the bat file and place in the same directory
runIt.bat

The runIt.bat files automatically saves as a text file, open it and save it as a batch file runIt.bat



Once you have all 3 downloaded be sure that all 3 are saved in the same directory.
Double click runIt.bat and there you go.

Source code below.
import java.io.*;
import javax.swing.*;
public class WordMatcher extends JTextArea{
public static void main(String[]args)throws IOException {

find();
String cont = JOptionPane.showInputDialog(null,"Would you like to match another word Y/N");

while(cont.equalsIgnoreCase("Y")){
find();
cont = JOptionPane.showInputDialog(null,"Would you like to match another word Y/N");
}

System.exit(0);
}
public static void find()throws IOException{
String str = "", lastTwo ="", words = "";
int counter = 0, found = 0, limit = 14;
FileReader fr = new FileReader("words.txt");
BufferedReader bf = new BufferedReader(fr);
JTextArea output = new JTextArea(40,40);
JScrollPane scroller = new JScrollPane(output);
str = JOptionPane.showInputDialog(null, "Enter last two letters of the word you wish to find a match for");

lastTwo = bf.readLine();
while ((bf.readLine()) != null){

if(str.equalsIgnoreCase(lastTwo.substring(lastTwo.length()-2))){
if(counter words += lastTwo+", ";
found++;
}
else{words += lastTwo+"\n"; counter = 0;}
counter++;
}
lastTwo = bf.readLine();
}

if(found > 0 ){
output.setText(words);
JOptionPane.showMessageDialog(null,scroller);
}
else{
output.setText("NO MATCHES FOUND");
JOptionPane.showMessageDialog(null,scroller);
}
}
}
End of WordMatcher made by Fabii

0 comments:

Inspector Gadget

  © Blogger template The Professional Template by Ourblogtemplates.com 2008

Back to TOP