Willace's Posts
Nairaland Forum › Willace's Profile › Willace's Posts
Celebrimbor:Thanks tho |
Celebrimbor:import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JScrollPane; import java.awt.Color; import java.awt.event.KeyListener; import java.awt.event.KeyEvent; import java.lang.Math; public class ChatBot extends JFrame implements KeyListener{ JPanel p=new JPanel(); JTextArea dialog=new JTextArea(20,50); JTextArea input=new JTextArea(1,50); JScrollPane scroll=new JScrollPane( dialog, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); String[][] chatBot={ //standard greetings {"hi","hello","hola","ola","howdy"}, {"hi","hello","hey"}, //question greetings {"how are you","how r you","how r u","how are u"}, {"good","doing well"}, //yes {"yes"}, {"no","NO","NO!!!!!!!"}, //default {"shut up","you're bad","noob","stop talking", "(michael is unavailable, due to LOL)"} }; public static void main(String[] args){ new ChatBot(); } public ChatBot(){ super("Chat Bot" ;setSize(600,400); setResizable(false); setDefaultCloseOperation(EXIT_ON_CLOSE); dialog.setEditable(false); input.addKeyListener(this); p.add(scroll); p.add(input); p.setBackground(new Color(255,200,0)); add(p); setVisible(true); } public void keyPressed(KeyEvent e){ if(e.getKeyCode()==KeyEvent.VK_ENTER){ input.setEditable(false); //-----grab quote----------- String quote=input.getText(); input.setText("" ;addText("-->You:\t"+quote); quote.trim(); while( quote.charAt(quote.length()-1)=='!' || quote.charAt(quote.length()-1)=='.' || quote.charAt(quote.length()-1)=='?' ){ quote=quote.substring(0,quote.length()-1); } quote.trim(); byte response=0; /* 0:we're searching through chatBot[][] for matches 1:we didn't find anything 2:we did find something */ //-----check for matches---- int j=0;//which group we're checking while(response==0){ if(inArray(quote.toLowerCase(),chatBot[j*2])){ response=2; int r=(int)Math.floor(Math.random()*chatBot[(j*2)+1].length); addText("\n-->Michael\t"+chatBot[(j*2)+1][r]); } j++; if(j*2==chatBot.length-1 && response==0){ response=1; } } //-----default-------------- if(response==1){ int r=(int)Math.floor(Math.random()*chatBot[chatBot.length-1].length); addText("\n-->Michael\t"+chatBot[chatBot.length-1][r]); } addText("\n" ;} } public void keyReleased(KeyEvent e){ if(e.getKeyCode()==KeyEvent.VK_ENTER){ input.setEditable(true); } } public void keyTyped(KeyEvent e){} public void addText(String str){ dialog.setText(dialog.getText()+str); } public boolean inArray(String in,String[] str){ boolean match=false; for(int i=0;i<str.length;i++){ if(str[i].equals(in)){ match=true; } } return match; } } Bros that is a source code for a chat bot i created . an AI follows the same process but a littlé bit advance. So it is possible my brother |
Celebrimbor:Y do u say dat, someone already did it so y can't i. It takes just belief and hardwork. My friend dont limit ur mind 2 thinking small. Peace |
Am currently learning java and i want to create an AI like a virtual Secretary. Any ideas please |
Please which app is best for programming on Android mostly java language |
Am in love with this girl and I already told her how I felt about her. She told me she is not interested that we are just friends. Yet anytime she sees me with another girl she is always VERY jealous. Wat do I do? |
Please which is more lucrative and has more job opportunities in nigeria: App development or server/web development? |
Am currently learning computer programing and web design. And am really in love with it. But it seems after learning I won't know what to do. Please how can I build a lucrative career in computer programing Your opinions will be appreciated |
Please am trying to start a blog but am confused about what to blog about Please I need matured advice Thanks |
I and my younger sister recently got admitted into higher institution recently. But due 2 financial constraints I couldn't go. Now am planning on using this year to learn software development which has always been my dream. I intend 2 start with web development. Wonderful ideas will be appreciated |
So person no fit wear 1 wrist watch again 4 naija. buy 4 am Na cus una like dey talk about Wetin no dey add anything 2 una life. skales dey wear 1 wrist watch for 1yr. Hw much don enter ur pocket. nubbish |
project7:Bros can have ur contact. I would like u 2 tutor me |
Please Where Can I find Good programmers in delta state(Warri). Cus it seems most of them are only in Lagos. |
Mine are:
Drake_lord Knows Sam Smith_Stay With me Avicii_the nights One Direction_you and i Drake_6pm In Dallas west Life_you raised Me up kierra Sheard_Indiscribable 2face_Spiritual Healing Rick Ross_ten Jesus pieces Wale_The Matrimony Feel free to add yours |
Would u give your beloved Mother A very Hot Slap For 50 Million Naira |
Who has d best vocals among Sam Smith, Justin Timberlake and Bruno mars
|
I have noticed Dat nice, sincere and Faithful Guys always Get Heart Broken. But D guys who are players and flirts always have good relationships. I have been a victim of This. Maybe it's because am 2 nice dats y we don't last long in our relationships. But My friends who are players and Flirts always good lasting relationships. I have never double dated before when am dating am always very polite, sincere and Nice 2 these girls.I But I know Of guys who Triple date sef. They are always Rude. At times even beating Their girlfriends. But they always last. Comments please |
Bros u don enter arm robber motor. Just politely return d gifts and Tell her hw u feel |
bad guy. This Kin father fit Bleep he son wife o |
Am thinking of going to NIIT while also studying part time. I have also been taking online courses on software. Pls how good is dis? |
My dream is to become a Software engineer. I dream of it every day. Right now am no longer thinking of going 2 school full time because of the nature of unemployment in our dear country. I just intend 2 study part time dats is if I even want 2 go school. I just want 2 learn d necessary things Dat I need 2 create a successful software company Because software is D future. Pls guys I need ur advice |
i am currently creating an android app. I dont know if i should use already existing source codes for that particular app, then modify it and add my own innovations or if i should just create a new source code from scratch please help |
I am currently Trying to create my own operating system and its not easy. Am trying to build it based on the linux kernel since its already an established kernel The process involves knowledge of c++, ARM assembly. Am currently in the multi tasking phase . Please any suggestion would help |
;