Jump to content

AI Assignment Questions

Featured Replies

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

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

Archived

This topic is now archived and is closed to further replies.

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.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.