Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace secondTask
  6. {
  7. class Program
  8. {
  9. static void Main()
  10. {
  11.  
  12.  
  13. Student Pesho = new Student("Pesho", new List<int>() { 1,2,3});
  14.  
  15. Pesho.Grades.Add("biology",new List<int>());
  16.  
  17.  
  18.  
  19.  
  20. }
  21. }
  22. public class Student
  23. {
  24. private string name;
  25. private List<Dictionary<string, List<int>>> grades;
  26. private Dictionary<string, List<int>> subject;
  27.  
  28.  
  29. public Student(string name)
  30. {
  31. this.name = name;
  32. this.grades = new List<Dictionary<string, List<int>>>();
  33. }
  34. public Student(string name, Dictionary<string, List<int>> subject)
  35. {
  36. this.name = name;
  37. this.grades.Add(subject);
  38. }
  39.  
  40. public string Name { get; set; }
  41. public List<Dictionary<string, List<int>>> Grades { get; set; }
  42. public Dictionary<string, List<int>> Subject {get; set;}
  43.  
  44.  
  45. }
  46. public static class Students
  47. {
  48. public static List<Student> students = new List<Student>();
  49.  
  50.  
  51.  
  52.  
  53. public static void AddStudentWithGrade(string name, Dictionary<string, List<int>> subject)
  54. {
  55. Student student = new Student(name,subject);
  56. students.Add(student);
  57. }
  58. public static void AddStudent(string name)
  59. {
  60. Student student = new Student(name);
  61. students.Add(student);
  62. }
  63.  
  64. public static string Print()
  65. {
  66. StringBuilder output = new StringBuilder();
  67.  
  68. foreach (var student in students)
  69. {
  70. string Grades = "";
  71. foreach (var grade in student.Grades)
  72. {
  73. Grades += grade.ToString().Split(',');
  74. }
  75. output.Append($"Name :{student.Name} | Grades :{Grades}");
  76. }
  77.  
  78.  
  79. return output.ToString();
  80.  
  81. }
  82.  
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement