-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssignment.cs
790 lines (610 loc) · 19.1 KB
/
Assignment.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace Classes
{
public class Student
{
//Question1
public string FullName;
public string Course;
public string University;
public string Email;
public string PhoneNumber;
public static int Level;
public Student()
{
}
//Question2
public Student(string name,string phoneNumber)
{
FullName = name;
PhoneNumber = phoneNumber;
}
public Student (string course,string university,string email)
{
Course = course;
University = university;
Email = email;
}
public Student(string name, string course, string university, string email, string phoneNumber)
{
FullName = name;
PhoneNumber = phoneNumber;
Course = course;
University = university;
Email = email;
}
//Question 3
//Question4
public void PrintInfo (Student student)
{
Console.WriteLine(student.FullName);
Console.WriteLine(student.Course);
Console.WriteLine(student.University);
Console.WriteLine(student.Email);
Console.WriteLine(student.PhoneNumber);
}
}
public class Student1
{
//Question5
private string FullName;
private string Course;
private string University;
private string Email;
private int PhoneNumber;
public void SetName(string name)
{
FullName = name;
}
public string GetName()
{
return FullName;
}
public void SetCourse (string course)
{
Course = course;
}
public string GetCourse ()
{
return Course;
}
public void SetUniverse (string university)
{
University = university;
}
public string GetUniverse ()
{
return University;
}
public void SetEmail (string email)
{
Email = email;
}
public string GetEmail ()
{
return Email;
}
public void SetPhone (int phone)
{
PhoneNumber = phone;
}
public int GetPhone ()
{
return PhoneNumber;
}
//question6
Student what =new Student("Ade","science","Unilag","ade@gmail.com","09087564734");
Student what1 =new Student("Ade","science","Unilag","ade@gmail.com","09087564734");
Student what2 =new Student("Ade","science","Unilag","ade@gmail.com","09087564734");
Student what3 =new Student("Ade","science","Unilag","ade@gmail.com","09087564734");
}
//Question7
public class StudenTest
{
}
//Question8 and 9,10,11,12,13,14
public class GSM:logs
{
public string Model;
public string Manufacturer;
public int Price;
public string Owner;
private string Colour;
private static string Nokia95;
public GSM (string nokia,string num):base(num)
{
Nokia95 = nokia;
}
public string AddCall (logs obj)
{
return AddCall(obj);
}
public string DeleteCall (logs obj)
{
return DeleteCall(obj);
}
public static string Getinfo()
{
return Nokia95;
}
public override string ToString()
{
return Price + Owner;
}
public void CoInfo (string colour)
{
Colour = colour;
}
public string CoGetinfo ()
{
return Colour;
}
public void PrintInfo()
{
string[] arr=new string[]{Owner,Model,Manufacturer,Price.ToString(),Colour};
Getinfo();
}
public int PriceCall(int price)
{
return price *End.Second;
}
public void PriceCalls (int price)
{
int f = 0;
f += PriceCall(price);
Console.WriteLine(f);
}
public GSM(string model, string manufacturer, int price, string owner,string num):base(num)
{
Model = model;
Manufacturer = manufacturer;
Price = price;
Owner = owner;
}
}
public class Battery
{
public int Model;
public int Idle;
public string Time;
public int Hours;
public string Talk;
private string Colour;
public void ColInfo (string colour)
{
Colour = colour;
}
public string ColGetinfo ()
{
return Colour;
}
public Battery(int model, int idle, string time, int hours, string talk)
{
Model = model;
Idle = idle;
Time = time;
Hours = hours;
Talk = talk;
}
}
public class Display
{
public int Size;
public string Colors;
private string Text;
public Display(int size, string colors)
{
Size = size;
Colors = colors;
}
public void TeInfo (string text)
{
Text = text;
}
public string TeGetinfo ()
{
return Text;
}
}
public enum BatteryType
{
Lechlanche,
Nickelion,
}
//Question 15
public class logs
{
public string number { get; set; }
public DateTime Date { get; set; }
public DateTime Begin { get; set; }
public DateTime End { get; set; }
public logs(string num)
{
number = num;
Date = DateTime.Now;
Begin = DateTime.UtcNow;
End = DateTime.UtcNow;
}
public string List()
{
string a = $"{number} {Date} {Begin} {End}";
return a;
}
}
public class Call<T> where T : logs
{
public string Listlogs(T obj)
{
return (obj.List());
}
}
public class lisTcall
{
public static void Enlist()
{
logs log=new logs("09876");
Call<logs> s=new Call<logs>();
Console.WriteLine(s.Listlogs(log));
}
}
//Question 20
public class Libarary:Book
{
public const string Name="LIb";
public static List<Book> books=new List<Book>();
public Libarary(string author,string title):base(title,author)
{
Author = author;
Title = title;
ISBN = GetISBN();
}
public void AddBook()
{
Console.WriteLine("Enter book Title: ");
string title = Console.ReadLine();
Console.Write("Enter book Author: ");
string author = Console.ReadLine();
Libarary b=new Libarary(author,title);
string f = b.ISBN;
books.Add(b);
Console.WriteLine($"The book ISBN is {f}");
}
public static void ListBooks()
{
if (books.Count==0)
{
Console.WriteLine("No book is not available");
}
else
{
foreach (var b in books)
{
if (books.Contains(b))
{
Console.WriteLine($"The book name is {b.Title} and the author is {b.Author}.The book ISBN is {b.ISBN} the book was relesed at{b.TimeReleased} ");
}
}
}
}
public void RemoveBook()
{
Console.WriteLine("Enter book Title: ");
string title = Console.ReadLine();
Console.Write("Enter book Author: ");
string author = Console.ReadLine();
Console.WriteLine("Enter book ISBN: ");
string isbn = Console.ReadLine();
foreach (var b in books)
{
if (b.ISBN==isbn && b.Author==author)
{
books.Remove(b);
break;
}
}
Console.WriteLine("The book has been removed successfully");
}
}
public class Book
{
public string Title { get; set; }
public string Author { get; set; }
public string ISBN { get; set; }
public DateTime TimeReleased { get; set; }
public Book(string title, string author)
{
Title = title;
Author = author;
ISBN = GetISBN();
TimeReleased = DateTime.UtcNow;
}
public string GetISBN()
{
Random random = new Random();
string r = random.Next(123456789).ToString();
return r;
}
//Question 21
public class TestClass
{
public static void Test()
{
Libarary b = new Libarary("g", "h");
b.AddBook();
b.RemoveBook();
Libarary.ListBooks();
}
}
//Question 22
public class School
{
public const string NameOfSchool = "Legacy";
public const string Address = "1,qqq street";
}
public class SchoolClass
{
public string Grade1 { get; set; }
public string Grade2 { get; set; }
public string Grade3 { get; set; }
public string Grade4 { get; set; }
public string Grade5 { get; set; }
public string Grade6 { get; set; }
public void GradeOneClass()
{
List<string> iGrade1s = new List<string>();
foreach (var teacher in Teachers.teachers)
{
if (teacher.Level == Grade1)
{
iGrade1s.Add($"{teacher.Name} {teacher.Age}");
}
}
foreach (var disciple in Disciples.disciples)
{
if (disciple.Level == Grade1)
{
iGrade1s.Add($"{disciple.Name} {disciple.Age}");
}
}
foreach (var studentse in Students.stud)
{
if (studentse.Level == Grade1)
{
iGrade1s.Add($"{studentse.Name} {studentse.Age}");
}
}
}
public void GradtwoClass()
{
List<string> grade2 = new List<string>();
foreach (var teacher in Teachers.teachers)
{
if (teacher.Level == Grade2)
{
grade2.Add($"{teacher.Name} {teacher.Age} {teacher.TeachersId}");
}
}
foreach (var disciple in Disciples.disciples)
{
if (disciple.Level == Grade2)
{
grade2.Add($"{disciple.Name} {disciple.Age} {disciple.DicipleId}");
}
}
foreach (var studentse in Students.stud)
{
if (studentse.Level == Grade2)
{
grade2.Add($"{studentse.Name} {studentse.Age}");
}
}
foreach (var person in grade2)
{
Console.WriteLine(person);
}
}
}
public class Students
{
public static List<Students> stud = new List<Students>();
public string Name { get; set; }
public string Level { get; set; }
public string Address { get; set; }
public int Age { get; set; }
public Students(string name, string address, int age, string level)
{
Name = name;
Address = address;
Age = age;
levels(level);
}
public string levels(string level)
{
Level = level;
return Level;
}
public static void RegisterStudents()
{
Console.Write("Enter your name: ");
string name = Console.ReadLine();
Console.Write("Enter your Address: ");
string address = Console.ReadLine();
Console.Write("Enter your Age");
int age = int.Parse(Console.ReadLine());
Console.Write("Enter level: ");
string level = Console.ReadLine();
Students s = new Students(name, address, age, level);
s.levels(level);
stud.Add(s);
Console.WriteLine("Welcome");
}
public static void ListStudents()
{
foreach (var f in stud)
{
Console.WriteLine($"Name: {f.Name} Age:{f.Age} Address:{f.Address} Class:{f.Level} ");
}
}
}
public class Teachers : Students
{
public static List<Teachers> teachers = new List<Teachers>();
public string TeachersId { get; set; }
public Teachers(string name, string address, int age, string level) : base(name, address, age, level)
{
TeachersId = Teacherid();
Name = name;
Address = address;
Age = age;
Levels(level);
}
public string Teacherid()
{
Random random = new Random();
string id = random.Next(1, 100).ToString();
return id;
}
public string Levels(string level)
{
Level = level;
return Level;
}
public static void RegisterTeachers()
{
Console.Write("Enter your name: ");
string name = Console.ReadLine();
Console.Write("Enter your Address: ");
string address = Console.ReadLine();
Console.Write("Enter your Age");
int age = int.Parse(Console.ReadLine());
Console.Write("Enter your class : ");
string level = Console.ReadLine();
Teachers s = new Teachers(name, address, age, level);
s.Levels(level);
string a = s.Teacherid();
teachers.Add(s);
Console.WriteLine($"Welcome your Id is {a}");
}
public static void ListTeachers()
{
foreach (var f in teachers)
{
Console.WriteLine($"Name: {f.Name} Age:{f.Age} Address:{f.Address} Class:{f.Level} Id:{f.TeachersId}");
}
}
}
public class Disciples : Students
{
public static List<Disciples> disciples = new List<Disciples>();
public string DicipleId { get; set; }
public Disciples(string name, string address, int age, string level) : base(name, address, age, level)
{
Name = name;
Address = address;
Age = age;
DicipleId = Discipleid();
Levels1(level);
}
public string Discipleid()
{
Random random = new Random();
string id = random.Next(100, 200).ToString();
return id;
}
public string Levels1(string level)
{
Level = level;
return Level;
}
public static void RegisterDisciples()
{
Console.Write("Enter your name: ");
string name = Console.ReadLine();
Console.Write("Enter your Address: ");
string address = Console.ReadLine();
Console.Write("Enter your Age");
int age = int.Parse(Console.ReadLine());
Console.Write("Enter your class : ");
string level = Console.ReadLine();
Disciples d = new Disciples(name, address, age, level);
d.Levels1(level);
string a = d.Discipleid();
disciples.Add(d);
Console.WriteLine($"Welcome your Id is {a}");
}
public static void ListDisciples()
{
foreach (var f in disciples)
{
Console.WriteLine($"Name: {f.Name} Age:{f.Age} Address:{f.Address} Class:{f.Level} Id:{f.DicipleId}");
}
}
}
public class TestSchool
{
public static void Test()
{
Disciples.RegisterDisciples();
Teachers.RegisterTeachers();
Students.RegisterStudents();
Disciples.ListDisciples();
Teachers.ListTeachers();
Students.ListStudents();
}
}
//Question 24
public class Items<T> where T : Property
{ }
public class Property
{
public string Cloth { get; set; }
public string Shoe { get; set; }
public string Drink { get; set; }
public string pencil { get; set; }
public Property(string cloth, string shoe, string drink, string pencils)
{
Cloth = cloth;
Shoe = shoe;
Drink = drink;
pencil = pencils;
}
}
//Question 25
public class Fraction
{
public float Numerator { get; set; }
public float Denominator { get; set; }
public Fraction(float numerator, float denominator)
{
Numerator = numerator;
Denominator = denominator;
}
public string Decimal()
{
string a = "";
for (int i = 0; i < Numerator/2 && i < Denominator/2; i++)
{
if (i % Numerator == 0 && i % Denominator == 0)
{
a= $"{Numerator}/{Denominator}";
break;
}
}
return a;
}
public float Division()
{
return Numerator / Denominator;
}
public string Numbers ()
{
return $"{Numerator} /{Denominator}";
}
}
}
}