• Post Reply Bookmark Topic Watch Topic
  • New Topic

Link Database and Main my Chatbot  RSS feed

 
David Coello
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am a new Java Developer. I am currently working on a Chatbot for school and so far I have created 2 main segments. First, I have the chatbot working at least ready for input and with 2 possible replies. The assignment requires me to have the conversation oriented towards a job interview, so I wrote the following:



I would like the database to be integrated with the main program and when the user enters a keyword like "job", or "hello", to retrieve and present that containing phrase from the database. I know I need some kind of array, a match or search and match, and a random function to choose an a reply.

My main statement:




Any help or guidance is greatly appreciated.

David
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Coello wrote:I would like the database to be integrated with the main program and when the user enters a keyword like "job", or "hello", to retrieve and present that containing phrase from the database. I know I need some kind of array, a match or search and match, and a random function to choose an a reply.

OK, well, what you've written for your "database" contents looks very much like an array to me, and it's an array where each element contains an array of 4 Strings (ie, an array of arrays); so how do you think that might be defined in Java? (actually, there's more than one answer).

As far as the random function goes, have a look at the Random class (java.util.Random).

It's the search part I don't quite follow; what are you supposed to search for? You mention a keyword, but don't really explain how it's used.

Also:
1. Class names should start with a CAPITAL letter; so it should be StartChat, not startChat.
2. You've defined a field called 'comline' and then don't do anything with it. What's it for?
3. you should generally avoid constructs like while(true) if you can. It's not a 100% rule, but see if you can think of a condition where you want the loop to stop instead.

HIH

Winston
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!