• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Link Database and Main my Chatbot

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Arch enemy? I mean, I don't like you, but I don't think you qualify as "arch enemy". Here, try this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic