-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
147 lines (122 loc) · 3.94 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Farmacie_1
{
class Program
{
static List<Farmacie> medList = new List<Farmacie>();
static Farmacie m = new Farmacie();
static void Main(string[] args)
{
Farmacie c1 = new Farmacie(1, "Parasinus", 20, 10);
medList.Add(c1);
bool close = true;
while (close)
{
Console.WriteLine("\nMenu\n" +
"1)Adauga medicament\n" +
"2)Sterge medicament\n" +
"3)Cauta medicament\n" +
"4)Afisare medicamente\n" +
"5)Exit\n\n");
Console.Write("Alegeti optiunea:");
int option = int.Parse(Console.ReadLine());
if (option == 1)
{
AdaugareMed();
}
else if (option == 2)
{
StergereMed();
}
else if (option == 3)
{
CautareMed();
}
else if (option == 4)
{
AfisareMed();
}
else if (option == 5)
{
Console.WriteLine("Exit");
close = false;
break;
}
else
{
Console.WriteLine("Optiunea invalida!");
}
}
}
public static void AdaugareMed()
{
Farmacie m = new Farmacie();
Console.WriteLine("Medicament Id:{0}", m.MedID = medList.Count + 1);
Console.Write("Numele medicamentului:");
m.MedNume = Console.ReadLine();
Console.Write("Pretul:");
m.MedPret = int.Parse(Console.ReadLine());
Console.Write("Numarul:");
m.X = m.MedNr = int.Parse(Console.ReadLine());
for (int i = 0; i < medList.Count; i++)
{
if (Farmacie.Compara(m, medList[i]) == Farmacie.LESS)
{
medList.Insert(i, m);
return;
}
}
medList.Add(m);
}
public static void StergereMed()
{
Farmacie m = new Farmacie();
Console.Write("Introduceti ID-ul medicamentului ce doriti sa il stergeti: ");
int Del = int.Parse(Console.ReadLine());
if (medList.Exists(x => x.MedID == Del))
{
medList.RemoveAt(Del - 1);
Console.WriteLine("Medicament ID - {0} a fost sters", Del);
}
else
{
Console.WriteLine("ID invalid");
}
medList.Add(m);
}
public static void CautareMed()
{
Farmacie m = new Farmacie();
Console.Write("Cautati prin ID:");
int find = int.Parse(Console.ReadLine());
if (medList.Exists(x => x.MedID == find))
{
foreach (Farmacie searchId in medList)
{
if (searchId.MedID == find)
{
Console.WriteLine("Medicament ID :{0}\n" +
"Medicamentul :{1}\n" +
"Pretul :{2}\n" +
"Numarul :{3}", searchId.MedID, searchId.MedNume, searchId.MedPret, searchId.MedNr);
}
}
}
else
{
Console.WriteLine("Medicamentul ID {0} nu a fost gasit", find);
}
}
public static void AfisareMed()
{
foreach (Farmacie searchId in medList)
{
Console.WriteLine(searchId.ToString());
}
}
}
}