-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
1212 lines (1054 loc) · 46.3 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System.Diagnostics;
using System.Globalization;
using Gpt4All;
namespace hello_world
{
public class Program
{
static void Main()
{
/*
//ondan küçük mü 1 den büyük mü?
Console.WriteLine("Please enter a number 1-10:");
var Value = Console.ReadLine();
Int64.Parse(Value);
Console.WriteLine(Value);
if (int.Parse(Value) >= 1 && int.Parse(Value) <= 10)
{
Console.WriteLine("Valid");
}
else
{
Console.WriteLine("Invalid");
}*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Write a program to count how many numbers between 1 and 100 are "divisible by 3" with no remainder.
//Display the count on the console
/*
for (int i = 1; i < 100; i++)
{
if (i % 3 == 0)Console.WriteLine(i);
}
*/
//////////////////////////////////////////////////////////////////////////////////////////////
//Write a program and continuously ask the user to enter a number or "ok" to exit.
//Calculate the sum of all the previously entered numbers and display it on the console.
// check ok or not.
//
/*
bool isAsking = true;
int Total = 0;
var ok = "ok";
while(isAsking)
{
Console.WriteLine("Please insert numbers. to sum up write (ok)");
var input = Console.ReadLine();
if (input == "Ok" || input == "OK" || input == "ok")
{
isAsking = false;
Console.WriteLine("Your total Expenses: " + Total);
break;
}
Total += Int32.Parse(input);
Console.WriteLine("This is total:" + Total);
Console.WriteLine("This is input:" + input);
*/
//////////////////////////////////////////////////////////////////////////////////////
///
//Write a program and ask the user to enter a number.
//Compute the factorial of the number and print it on the console.
//For example, if the user enters 5, the program should calculate 5 x 4 x 3 x 2 x 1 and
//display it as 5! = 120
/*
Console.Write("Enter a number: ");
var factorial = Convert.ToInt32(Console.ReadLine());
var fctrl = factorial--;
var sum = fctrl;
for (int i = factorial; i >= 1; i--)
{
fctrl *= i;
Console.WriteLine("debug:"+i);
if (i == 1)
{
Console.WriteLine("factorial sum : " + sum +"! = " + fctrl);
}
}*/
/////////////////////////////////////////////////////////////////////////////////////
//Write a program that picks a random number between 1 and 10.
//Give the user 4 chances to guess the number.
//If the user guesses the number, display “You won"; otherwise, display “You lost".
//(To make sure the program is behaving correctly,
//you can display the secret number on the console first.)
/*
var rand = new Random();
var solution = rand.Next(0, 10);
for (int i = 0; i < 4; i++)
{
var bet = Convert.ToInt32(Console.ReadLine());
if (bet == solution)
{
Console.WriteLine("You Won !! " + solution);
break;
}
else Console.WriteLine("You lost, please try again. ");
}
*/
///////////////////////////////////////////////////////////////////////////////////////
//Write a program and ask the user to enter a series of numbers separated by comma.
//Find the maximum of the numbers and display it on the console.
//For example, if the user enters “5, 3, 8, 1, 4", the program should display 8.
/*
var charsToRemove = new string[] { "@", ",", ".", ";", "'" };
Console.WriteLine("Please enter 4 numbers separeted with (,)");
var list = Console.ReadLine();
foreach (var c in charsToRemove)// these will remove ","
{
list = list.Replace(c, string.Empty);
}
var maxNumber = list.Max();//string to bigeset number
Console.WriteLine("Max number is: " + maxNumber);
*/
///////////////////////////////////////////////////////////////////////////////////////
// A person already posted so he will upload names that liked his post
//If no one likes your post, it doesn't display anything.
//If only one person likes your post, it displays: [Friend's Name] likes your post.
//If two people like your post, it displays: [Friend 1] and[Friend 2] like your post.
//If more than two people like your post, it displays: [Friend 1], [Friend 2] and[Number of Other People] others like your post.
/*
var names = new List<string>();
string name ;
bool Posted = false;
int others;
while (!Posted)
{
Console.WriteLine("Please enter whom liked ?");
name = Console.ReadLine();
if (!string.IsNullOrEmpty(name))
{
names.Add(name);
}
else
{
Posted = true;
if (names.Count == 1)
{
Console.WriteLine(names[0] + "likes your post.");
}
if (names.Count == 2)
{
Console.WriteLine(names[0] + "and" + names[1] + "liked your post");
}
if (names.Count >= 3)
{
Console.WriteLine("{0}, {1} and {2} others like your post", names[0], names[1], names.Count - 2);
}
}
}
*/
/////////////////////////////////////////////////////////////////////////////////
//Write a program and ask the user to enter their name. Use an array to reverse the name and
//then store the result in a new string. Display the reversed name on the console.
/*
var name = Console.ReadLine();
char[] charArr = name.ToCharArray(); //string to char
Array.Reverse(charArr);
name = new string(charArr); //char array to string
Console.WriteLine("Reversed :" + name);
*/
/////////////////////////////////////////////////////////////////////////////////////
//Write a program and ask the user to enter 5 numbers.
//If a number has been previously entered, display an error message and ask the user to re-try.
//Once the user successfully enters 5 unique numbers,
//sort them and display the result on the console.
/*
bool norepeat = false;
int number;
Console.WriteLine("please enter 5 digit number.");
number = Convert.ToInt32(Console.ReadLine());
char[] list = number.ToString().ToCharArray();
var dict = new Dictionary<int, int>();
foreach (var value in list)
{
// When the key is not found, "count" will be initialized to 0
dict.TryGetValue(value, out int count);
dict[value] = count + 1;
if (count >= 1)
{
Console.WriteLine("Please try again you made a duplicate.");
}
else
{
norepeat = true;
}
}
if (norepeat)
{
Array.Sort(list);
Console.WriteLine("here is conclusion : ");
foreach (var item in list)
{
Console.WriteLine(item);
}
}
*/
////////////////////////////////////////////////////////////////////////////
//Write a program and ask the user to continuously enter a number or type "Quit" to exit.
//The list of numbers may include duplicates. Display the unique numbers that the user has entered.
/*
bool isAsking = true;
while (isAsking)
{
Console.WriteLine("Please insert numbers. which gonna show unique numbers if you write (Quit) gonna quit application.");
var input = Console.ReadLine();
if (input == "Quit")
{
isAsking = false;
break;
}
else
{
bool norepeat = false;
int number;
number = Convert.ToInt32(input);//girdi alınıp int dönüştü
char[] list = number.ToString().ToCharArray(); // int to char array
var dict = new Dictionary<int, int>();
foreach (var value in list) // burda char arrayde duplicate lerin bulunup silinmesi ve gösterilmesi gerek.
{
// When the key is not found, "count" will be initialized to 0
dict.TryGetValue(value, out int count);
dict[value] = count + 1;
if (count == 0)
{
norepeat = true;
}
else
{
norepeat = false;
Console.WriteLine("deleting duplicates");
int[] Aint = list.Select(i => Int32.Parse(i.ToString())).ToArray();
int[] distinct = Aint.Distinct().ToArray();
Console.WriteLine("Here is your corrected unique numbers:");
foreach (var item in distinct)
{
Console.WriteLine(item);
}
}
}
if (norepeat)
{
Array.Sort(list);
Console.WriteLine("here is your unique numbers :");
foreach (var item in input)
{
Console.WriteLine(item);
}
}
}
}
*/
///////////////////////////////////////////////////////////////////////////////////
//Write a program and ask the user to supply a list of comma separated numbers(e.g 5, 1, 9, 2, 10).
//If the list is empty or includes less than 5 numbers, display "Invalid List" and ask the user to re-try;
//otherwise, display the 3 smallest numbers in the list.
/*
var charsToRemove = new string[] { "@", ",", ".", ";", "'" };
Console.WriteLine("Please enter 5 numbers separeted with (,) in range of 1-9");
var list = Console.ReadLine();
foreach (var c in charsToRemove)// these will remove ","
{
list = list.Replace(c, string.Empty);
}
if (5 == list.Length)
{
char[] charArr = list.ToCharArray();
//
// Burda list in string ten char array a cevrilmesi ve ondan sonra sayıların tek tek arraya atılması gerek.
int[] Liste = Array.ConvertAll(charArr, c => (int)Char.GetNumericValue(c));
List<int> List = new List<int>(Liste);
int i = 0;
int small = 0;
//integer array declaration
int[] arr = new int[5];
//mine was different after this This more readable :)
var Smalls = new List<int>();
while (Smalls.Count < 3)
{
//assign fist element to the 'small'
//compare it with other array elements
small = List[0];
foreach (var number in List)
{
if (small > List[i])
small = List[i];
}
Smalls.Add(small);
List.Remove(small);
}
Smalls.Sort();
foreach (var item in Smalls)
{
Console.WriteLine("3 smallest numbers : " + item);
}
}
else
{
Console.WriteLine("please enter 5 numbers and in 1 digits please. Also not empty please.");
}
}
*/
////////////////////////////////////////////////////////////////////////////////////////
///Mine works differantly soo I want to preserve it
/*
//assign fist element to the 'small'
//compare it with other array elements
small = Aint[0];
int firstSmall;
int secondSmall;
int thirdSmall;
for (i = 1; i < 5; i++)
{
//compare if small is greater than of any element of the array
//assign that element in it.
if (small > Aint[i])
small = Aint[i];
}
firstSmall = small;
int indexToRemove = Array.IndexOf(Aint, firstSmall);
Aint = Aint.Where((source, index) => index != indexToRemove).ToArray();
small = Aint[0];
for (i = 1; i < 4; i++)
{
//compare if small is greater than of any element of the array
//assign that element in it.
if (small > Aint[i])
small = Aint[i];
}
secondSmall = small;
indexToRemove = Array.IndexOf(Aint, secondSmall);
Aint = Aint.Where((source, index) => index != indexToRemove).ToArray();
small = Aint[0];
for (i = 1; i < 3; i++)
{
//compare if small is greater than of any element of the array
//assign that element in it.
if (small > Aint[i])
small = Aint[i];
}
thirdSmall = small;
indexToRemove = Array.IndexOf(Aint, thirdSmall);
Aint = Aint.Where((source, index) => index != indexToRemove).ToArray();
small = Aint[0];
foreach (var item in Aint)
{
Console.WriteLine(" last list elements : " + item);
}
//finally print the smallest elemeent of the integer array
Console.WriteLine("Smallest elements in array are : " + firstSmall + " " + secondSmall + " " + thirdSmall);
}
else
{
Console.WriteLine("please enter 5 numbers and in 1 digits please. Also not empty please.");
}
*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7
///7/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//STRİNGS AND STRİNGBUİLDER PART OF THE EXERCİSES
//
//string to tl format
/*
string para = String.Format("{0:C2}", 45.50);
Console.WriteLine(para);
*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Write a program and ask the user to enter a few numbers separated by a hyphen.
//Work out if the numbers are consecutive.
//For example, if the input is "5-6-7-8-9" or "20-19-18-17-16", display a message: "Consecutive";
//otherwise, display "Not Consecutive".
/*
string Input;
Console.WriteLine(" \n Your numbers are : " + ConsequetivityChecker(Input = Console.ReadLine()));
*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////7
///// Write a program and ask the user to enter a few numbers separated by a hyphen.
///If the user simply presses Enter, without supplying an input, exit immediately;
///otherwise, check to see if there are duplicates. If so, display "Duplicate" on the console
/*
string input;
Console.WriteLine(" \n Your numbers are : " + DuplicateChecker(input = Console.ReadLine()));
*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///Write a program and ask the user to enter a time value in the 24-hour time format (e.g. 19:00).
///A valid time should be between 00:00 and 23:59. If the time is valid, display "Ok";
///otherwise, display "Invalid Time". If the user doesn't provide any values, consider it as invalid time.
/*
Console.WriteLine("please input as 00:00 type .");
string text;
Console.WriteLine("Your given string is : " + HourCorrectness(text = Console.ReadLine()));
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///Write a program and ask the user to enter a few words separated by a space.
///Use the words to create a variable name with PascalCase.
///For example, if the user types: "number of students", display "NumberOfStudents".
///Make sure that the program is not dependent on the input.
///So, if the user types "NUMBER OF STUDENTS", the program should still display "NumberOfStudents".
///
///takee input, make all of them lower case, make evey word an array element then uppercase first char.
/*
string firstLetterOfEachWord;
Console.WriteLine("FirstLetterOfEach word : " + PascalCase_er(firstLetterOfEachWord = Console.ReadLine()));
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///Write a program and ask the user to enter an English word.
///Count the number of vowels (a, e, o, u, i) in the word.
///So, if the user enters "inadequate", the program should display 6 on the console.
///
/*
string input;
Console.WriteLine(CountSesliHarf(input = Console.ReadLine()));
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///File RELATED CODES
/// Just for try
/*
var files = Directory.GetFiles(@"D:\Belgelerim\Other documents for the your life force comander", "*.*" , SearchOption.AllDirectories);
foreach (var item in files)
{
Console.WriteLine(item);
}
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///Write a program that reads a text file and displays the number of words.
/*
int wordCount;
string whole_text = File.ReadAllText(@"D:\YOUTUBE VİDEOS/NOTLAR.txt");
char[] delimiters = new char[] { ' ', '\r', '\n' };
wordCount = whole_text.Split(delimiters, StringSplitOptions.RemoveEmptyEntries).Length;
Console.WriteLine("here is your word count: " + wordCount);
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Write a program that reads a text file and displays the longest word in the file.
/*
string whole_text = File.ReadAllText(@"D:\YOUTUBE VİDEOS/NOTLAR.txt");
var words = new List<string>(whole_text.Split(new char[] { }, StringSplitOptions.RemoveEmptyEntries));
Console.WriteLine(words.Count);
if (words.Count > 0)
{
int longestIndex = 1;
string longestWord = words[0];
for (int i = 0; i < words.Count; i++)
{
string item = words[i];
if (item.Length > longestWord.Length)
{
longestWord = item;
longestIndex = i + 1;
}
}
Console.WriteLine("Longest Word: {0}\nFound at Position {1}", longestWord, longestIndex);
}
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////77
///Exercise 1: Design a Stopwatch,provide two methods: Start and Stop.We call the start method first, and the stop method next.
///Duration should be a value in TimeSpan.
///Display the duration on the console.
///We should also be able to use a stopwatch multiple times.So we may start and stop it and then
///start and stop it again. Make sure the duration value each time is calculated properly.
///We should not be able to start a stopwatch twice in a row (because that may overwrite the initial start time).
///So the class should throw an InvalidOperationException if its started twice.
///make stop and start a seperate method.
/*
bool exit = false;
DateTime start = default, stop = default;
string testString = "Test";
bool running = false;
while (!exit)
{
string input = Console.ReadLine();
if (input.ToLower() == "start" && !running)
{
running = true;
start = DateTime.Now;
Console.WriteLine(start);
}
else if (input.ToLower() == "stop")
{
running = false;
stop = DateTime.Now;
Console.WriteLine(stop);
var duration = start - stop;
Console.WriteLine(duration);
}
else if (input.ToLower() == "exit")
{
exit = true;
}
else if (input.ToLower() == "start" && running)
{
throw new InvalidOperationException("You shouldn't start twice.");
}
}
/// I will try same thing with methods usign get set properties
/// first try was a bit in need of ref so we change ways
var Watch = new Watch();
bool exit = false;
bool running = false;
while (!exit)
{
string input = Console.ReadLine();
if (input.ToLower() == "start" && !running)
{
running = true;
Watch.SetTimerStart();
}
else if (input.ToLower() == "stop")
{
running = false;
Watch.SetTimerEnd();
}
else if (input.ToLower() == "exit")
{
exit = true;
}
else if (input.ToLower() == "start" && running)
{
throw new InvalidOperationException("You shouldn't start twice.");
}
}
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////
///Design a class called Post. This class models a StackOverflow post. It should have properties for title,
///description and the date / time it was created.We should be able to up - vote or down - vote a post.
///We should also be able to see the current vote value.In the main method, create a post,up - vote and down - vote
///it a few times and then display the the current vote value.
///In this exercise, you will learn that a StackOverflow post should provide methods for up - voting and down - voting.
///You should not give the ability to set the Vote property from the outside, because otherwise, you may accidentally change the votes
///of a class to 0 or to a random number.And this is how we create bugs in our programs.
///The class should always protect its state and hide its implementation detail.
//Post
///rate 2dislikes 0 likes
///to vote up write like or dislike to dislike
///title
///description
///
///all of those should be from methods.
/*
var StackOverFlowPost = new StackOverFlowPost();
bool exit = false;
while (!exit)
{
var input = Console.ReadLine();
if (input.ToLower() == "dislike")
{
StackOverFlowPost.Dislike();
}
else if (input.ToLower() == "like")
{
StackOverFlowPost.Like();
}
else if (input.ToLower() == "post")
{
StackOverFlowPost.Post();
}
else if (input.ToLower() == "exit")
{
exit = true;
}
}
*/
//////////////////////////////////////////////////////////////////////////////////////////////
///design a stack that takes numbers and stacks them to a stack and play with them .
///pop them clear them check whether null values entered or not
/*
var Stack = new Stackk();
Stack.Stack_items(10);
bool exit = false;
Console.WriteLine("Please just write what you want to push . input numbers .(pop) to pop ,(clear) to clear ,(print) to print the stack, (test) to test the code,(exit) to exit the application ");
while (!exit)
{
try
{
var input = Console.ReadLine();
if (input == null || input == "0" || input == "" || input == " ")
{
throw new InvalidOperationException();
}
else if (input.ToLower() == "pop")
{
Stack.Pop();
}
else if (input.ToLower() == "clear")
{
Stack.Clear();
}
else if (input.ToLower() == "printstack" || input.ToLower() == "print")
{
Stack.printStack();
}
else if (input.ToLower() == "test")
{
Stack.Push(1);
Stack.Push(2);
Stack.Push(3);
Console.WriteLine(Stack.Pop());
Console.WriteLine(Stack.Pop());
Console.WriteLine(Stack.Pop());
}
else if (input.ToLower() == "exit")
{
exit = true;
}
else
{
Stack.Push(input);
}
}
catch (InvalidOperationException e)
{
Console.WriteLine("please don't insert null values!");
continue;
}
}
*/
//////////////////////////////////////////////////////////////////////////////////////////////
///desgin a dbconnection between classes and over ride the methods. Using Abstract classes.
//
/*
bool exit = false;
string ConnectionString =default;
TimeSpan Timeout = default;
Console.WriteLine("Please just write what you want to connect , ex. sqlconnect / azureconnect . ");
while (!exit)
{
try
{
var input = Console.ReadLine();
if (input == null || input == "0" || input == "" || input == " ")
{
throw new InvalidOperationException();
}
else if (input.ToLower() == "sqlconnect")
{
Sqlconnect sqlconnect = new Sqlconnect(ConnectionString, Timeout);
sqlconnect.ServerOpen(input, TimeSpan.FromSeconds(15));
}
else if (input.ToLower() == "azureconnect")
{
Azureconnect azureconnect = new Azureconnect(ConnectionString, Timeout);
azureconnect.ServerOpen(input, TimeSpan.FromSeconds(15));
}
else if (input.ToLower() == "exit")
{
exit = true;
}
else
{
// add a timer?
}
}
catch (InvalidOperationException e)
{
Console.WriteLine("please don't insert null values!");
continue;
}
}
*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
Workflow workflow = new Workflow(new List<IActivity>());
workflow.Activities.Add(new Videouploader());
workflow.Activities.Add(new DataBase());
workflow.Activities.Add(new Webservice());
WorkflowEngine.Run(workflow);
Console.ReadLine();
*/
// load the model
var modelFactory = new ModelFactory();
using var model = modelFactory.LoadModel("./path/to/ggml-gpt4all-j-v1.3-groovy.bin");
var input = "Name 3 Colors";
// request a prediction
var result = await model.GetStreamingPredictionAsync(
input,
PredictRequestOptions.Defaults);
// asynchronously print the tokens as soon as they are produces by the model
await foreach (var token in result.GetPredictionStreamingAsync())
{
Console.Write(token);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//THE METHODS RELATED TO THOSE UPWARDS.
public static void DislikeClicked()
{
}
public static string WriteThePost(string dislike, string like, string title, string description)
{
return dislike;
}
public static string ConsequetivityChecker(string Input)
{
bool isConsecutive = false;
bool isAssemding = false;
bool isDesending = false;
var charsToRemove = new string[] { "@", ",", ".", ";", "'", " " };
Console.WriteLine("Please enter number separated with (,) :");
foreach (var c in charsToRemove)// these will remove ","
{
Input = Input.Replace(c, string.Empty);
}
if (!string.IsNullOrWhiteSpace(Input))
{
var Lenght = Input.Length;
for (int i = 0; i < Lenght / 2; i++)// i yi arttırarak başta 1 i sonra 12 yi baz alıyor.
{
// new String containing the starting
// substring of input String
String new_str = Input.Substring(0, i + 1);
// converting starting substring into number
int num = int.Parse(new_str);
// while loop until the new_String is
// smaller than input String
while (new_str.Length < Lenght)
{
// next number
num++;
// concatenate the next number
new_str = new_str + String.Join("", num);
}
// check if new String becomes equal to
// input String
if (new_str.Equals(Input))
{
return "IS Consequetive: " + Input + " ," + new_str;
isAssemding = true;
}
}
Lenght = Input.Length;
for (int i = 0; i < Lenght / 2; i++)// i yi arttırarak başta 1 i sonra 12 yi baz alıyor.
{
// new String containing the starting
// substring of input String
String new_str = Input.Substring(0, i + 1);
// converting starting substring into number
int num = int.Parse(new_str);
// while loop until the new_String is
// smaller than input String
while (new_str.Length < Lenght)
{
// next number
num--;
// concatenate the next number
new_str = new_str + String.Join("", num);
}
// check if new String becomes equal to
// input String
if (new_str.Equals(Input))
{
return "IS Consequetive: " + Input;
isDesending = true;
}
else
return "NOT Consequetive: " + Input + " ," + new_str;
isConsecutive = false;
}
if (isAssemding || isDesending)
{
return "LastResult : TRUE";
}
else
{
return "LastResult : False";
}
}
return "It is emtyp sir";
}
// These are exercise for interface activity.
public interface IActivity
{
void Execute();
}
public class Videouploader : IActivity
{
public void Execute()
{
Console.WriteLine("please 'nsert a v'deo to the app ");
Console.WriteLine("uploading video...");
}
}
public class Webservice : IActivity
{
public void Execute()
{
Console.WriteLine("Video Encoding Started...");
Console.WriteLine("Videouploading sent to your mail.");
}
}
public class DataBase : IActivity
{
public void Execute()
{
Console.WriteLine("Process'ng status (uploading)");
}
}
public class Workflow
{
public List<IActivity> Activities { get; }
public Workflow(List<IActivity> activities)
{
Activities = activities;
}
}
public class WorkflowEngine
{
public static void Run(Workflow workflow)
{
foreach (var activity in workflow.Activities)
{
if (activity == null)
throw new ArgumentException("Activities cannot be null.");
activity.Execute();
}
}
}
public static string DuplicateChecker(string input)
{
var charsToRemove = new string[] { "@", ",", ".", ";", "'", " " };
Console.WriteLine("Please insert numbers. we gonna show duplicate numbers , if you press (enter) algorithm gonna quit application.");
if (string.IsNullOrWhiteSpace(input))
{
return "understood Quitting initiated...";
}
else
{
foreach (var c in charsToRemove)// these will remove ","
{
input = input.Replace(c, string.Empty);
}
if (input.Distinct().Count() == input.Length)
{
return "CLEAR";
}
else
return "Duplicate exists!";
}
}
public static string HourCorrectness(string text)
{
CultureInfo invariant = System.Globalization.CultureInfo.InvariantCulture;
DateTime dt;
if (DateTime.TryParseExact(text, "HH:mm", invariant, DateTimeStyles.None, out dt))
{
return "Valid";
}
else
{
// handle the fact you cannot parse the datetime
return "Invalid";
}
}
public static string PascalCase_er(string firstLetterOfEachWord)
{
var LowCase = firstLetterOfEachWord.ToLower();
firstLetterOfEachWord =
string.Join(" ", LowCase.Split(' ').ToList()
.ConvertAll(word =>
word.Substring(0, 1).ToUpper() + word.Substring(1)
)
).Replace(" ", "");
return firstLetterOfEachWord;
}
public static string CountSesliHarf(string input)
{
string[] sesliler = { "a", "e", "o", "u", "i" };
var charSesliler = sesliler.SelectMany(x => x.ToCharArray());
int Count = 0;
foreach (var ses in charSesliler)
{
Count += input.Count(f => (f == ses));
}
input = Convert.ToString(Count);
return input;
}
/// <summary>
/// NEW CLASSES
/// </summary>
public abstract class Dbconnection
{
public abstract void ServerOpen(string ServerKey, TimeSpan timeout);
public abstract void ServerClose();