Загрузка...

6. Alternative Behavior (Calculator) | Chatbot WPF C#

An alternative mode of using the program which can be seen after using the program for the 2nd+ time.

Subscribe! ► https://www.youtube.com/c/QuasimodoPrograms?sub_confirmation=1

A series of several videos on creating a WPF C# chatbot using Visual Studio.

The non-first launch is going to have its own plot.
Unlike the first launch conversation, the chatbot will clear its textbox when you press the Send button.
After that the chatbot will display its message.
Then we need to increase the plot int field by 1.
Let's run the chatbot.
So, right now our conversation cannot continue until we develop it further.
Let's proceed to plot 1.
This time we'll make the chatbot act in a different way.
Instead of asking information about you, the chatbot will ask 2 numbers and then add them.
Let's put it in a try-catch block.
We will need 2 int fields to store the numbers.
We are going to set the first number to the text typed by you and converted to Int32.
When we launched the chatbot, there was a blank line before the introduction sentence. Let's remove it.
Also, instead of accumulating text like during the first conversation, we are going to substitute the text in the chatbot's textbox.
So, if your answer is successfully parsed as Int32, the chatbot will ask for the second number.
But if you send empty or non-number text, the code will abandon the try block and jump to the catch block.
If so, the chatbot will inform us about the error.
Also, the chatbot will finish working as a calculator.
Even this scenario needs its own plot number.
Let's get back to the case when the first number is parsed without errors.
We sent numbers so we didn't get an error.
Parsing the second number is identical to parsing the first one.
Now, the chatbot can display the sum of the 2 numbers.
We are going to create a loop where the chatbot will ask for 2 numbers and add them.
Plot 4 is the case where there is an error because the chatbot cannot parse the text as a number.
When the chatbot finishes working as a calculator, it provides you with an option to erase its memory.
If you decide to erase the chatbot's memory, it will try to write the appropriate bool field to the text file.
Let's see if the chatbot suggests to erase its memory.

More WPF Chatbot ► https://youtube.com/playlist?list=PL3g0PHY_11p4PD7Dt4X9KCLpOiyCsW8UD

Видео 6. Alternative Behavior (Calculator) | Chatbot WPF C# канала Quasimodo Programs
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять