Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace secondTask
- {
- class Program
- {
- static void Main()
- {
- Student Pesho = new Student("Pesho", new List<int>() { 1,2,3});
- Pesho.Grades.Add("biology",new List<int>());
- }
- }
- public class Student
- {
- private string name;
- private List<Dictionary<string, List<int>>> grades;
- private Dictionary<string, List<int>> subject;
- public Student(string name)
- {
- this.name = name;
- this.grades = new List<Dictionary<string, List<int>>>();
- }
- public Student(string name, Dictionary<string, List<int>> subject)
- {
- this.name = name;
- this.grades.Add(subject);
- }
- public string Name { get; set; }
- public List<Dictionary<string, List<int>>> Grades { get; set; }
- public Dictionary<string, List<int>> Subject {get; set;}
- }
- public static class Students
- {
- public static List<Student> students = new List<Student>();
- public static void AddStudentWithGrade(string name, Dictionary<string, List<int>> subject)
- {
- Student student = new Student(name,subject);
- students.Add(student);
- }
- public static void AddStudent(string name)
- {
- Student student = new Student(name);
- students.Add(student);
- }
- public static string Print()
- {
- StringBuilder output = new StringBuilder();
- foreach (var student in students)
- {
- string Grades = "";
- foreach (var grade in student.Grades)
- {
- Grades += grade.ToString().Split(',');
- }
- output.Append($"Name :{student.Name} | Grades :{Grades}");
- }
- return output.ToString();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement