Last active
September 29, 2016 18:15
-
-
Save dz0/c66fe4be75ab7fbf25771ba73cd2fcf7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace ConsoleApplication4_ChatBot | |
| { | |
| class Program | |
| { | |
| static void Butkevicius(string input) | |
| { | |
| string[] iterpiniai = { "gal", "sakyciau", "labai", "turbut" }; | |
| string[] zodziai = input.Split(' '); | |
| Random rnd = new Random(); | |
| foreach(string zod in zodziai) | |
| { | |
| int kuris = rnd.Next(0, iterpiniai.Length - 1); // atsitiktinis iterpinio nr. | |
| Console.Write(iterpiniai[kuris] + " " + zod +" "); | |
| } | |
| Console.WriteLine(); | |
| } | |
| // funkcija React, reaguoja i ivesta teksta | |
| static void React(string input) | |
| { | |
| if (input.ToUpper() == input && input != "") | |
| Console.WriteLine("Prasome kalbeti ramiau.."); | |
| if (input == "") | |
| Console.WriteLine("Ka manai?"); | |
| else if (input.EndsWith("?")) | |
| Console.WriteLine("Taip arba ne..."); | |
| else if (input.EndsWith("...")) | |
| Butkevicius(input); | |
| else | |
| Console.WriteLine("jo jo, " + input); // paantrina teigini | |
| } | |
| static void Main(string[] args) | |
| { | |
| // isidemim naudotojo varda | |
| //Console.WriteLine("Kas tu? "); | |
| //string vardas = Console.ReadLine(); | |
| //Console.WriteLine("Labas " + vardas); | |
| // Nuskaitom pokalbiu istorija | |
| string[] istorija; | |
| try | |
| { | |
| istorija = System.IO.File.ReadAllLines("Chat.txt"); | |
| for (int i = 0; i < istorija.Length; i++) | |
| { | |
| Console.WriteLine(istorija[i]); // atspausdinam buvusias eilutes | |
| React(istorija[i]); // ir reakcijas i jas | |
| } | |
| } | |
| catch (System.IO.FileNotFoundException ) | |
| { | |
| Console.WriteLine( "Anksciau mes nekalbejom" ); | |
| } | |
| Console.WriteLine("-----------------"); | |
| //string text = System.IO.File.ReadAllText(); | |
| // input isidemes naudotojo ivesta teksta | |
| string input =""; | |
| while(input != "ate") // kol nebus parasyta "ate" | |
| { | |
| React(input); | |
| input = Console.ReadLine(); // ir nuskaito nauja input'a | |
| System.IO.File.AppendAllText("Chat.txt", input+"\n"); // papildom faila | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment