-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDAW_Tema1.cs
More file actions
101 lines (86 loc) · 2.85 KB
/
DAW_Tema1.cs
File metadata and controls
101 lines (86 loc) · 2.85 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
internal class Program
{
static void Main(string[] args)
{
Materie matematica=new Materie("Matematica","3 ore");
Materie informatica = new Materie("Informatica", "2 ore");
Materie istorie = new Materie("Istorie", "1 ora");
Materie fizica = new Materie("Fizica", "2 ore");
List<Materie> materii = new List<Materie>();
List<Student> studenti = new List<Student>();
materii.Add(fizica);
materii.Add(informatica);
studenti.Add(new Student("Nedelcu", "Dragos", materii));
materii.Clear();
materii.Add(matematica);
materii.Add(fizica);
materii.Add(informatica);
materii.Add(istorie);
studenti.Add(new Student("Popescu", "Ion", materii));
materii.Clear();
materii.Add(matematica);
materii.Add(istorie);
studenti.Add(new Student("Protopopescu", "Protoion", materii));
materii.Clear();
foreach (Student s in studenti)
{
s.Afisare();
Console.Write("--------------------------------------\n");
}
Console.ReadKey();
}
class Materie
{
private string titlu, durata;
public Materie()
{
titlu = "";
durata = "";
}
public Materie(string titlu1,string durata1)
{
titlu = titlu1;
durata = durata1;
}
public void Afisare()
{
Console.Write(titlu + " (durata: " + durata + ")");
}
}
class Student
{
private string nume,prenume;
private List<Materie> materii;
public Student()
{
nume = "";
prenume = "";
materii = null;
}
public Student(string nume1,string prenume1,List<Materie>materii1)
{
nume = nume1;
prenume = prenume1;
materii = new List<Materie>();
foreach (Materie x in materii1)
materii.Add(x);
}
public void Afisare()
{
Console.Write("Studentul " + nume + " " + prenume + " are urmatoarele materii:\n");
foreach(Materie x in materii)
{
x.Afisare();
Console.Write("\n");
}
}
}
}
}