Jump to content

AI Assignment Questions


FatCow

Recommended Posts

I have been given a simple ChatBot program for my Computer Science class, but I do not understand most of the codes and methods included in it :unsure:

 

Some of the things I do not understand in the program are "psn >= 0", "lastChar", and "substring".

 

If anyone of you guys can spare some of your time to explain these to me, that would be great!

 

I have attached the actual ChatBot file, so you could take a look at it (I had to upload the text file, because I couldn't upload the actual java).

Magpie4.txt

Link to comment
Share on other sites

String.substring() returns middle part of string. If length is missing it's probably going to the end of string.

lastChar is of course last character, last letter, of the string.

That code was checking whether it's dot.

 

psn is variable name. Shortcut from position-index inside of string.

Edited by Sensei
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.