-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProducentKartotek.cs
89 lines (79 loc) · 2.77 KB
/
ProducentKartotek.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mip2011
{
public class ProducentKartotek
{
//Er også lavet som singleton for kun at have ét kartotek
private static ProducentKartotek producentKartotek = new ProducentKartotek();
private VoresListe<Producent> producentListe;
public VoresListe<Producent> ProducentListe
{
get { return producentListe; }
set { producentListe = value; }
}
/* This is the private constructor meaning that it is not possible to instantiate
the class outside the class */
private ProducentKartotek()
{
this.producentListe = new VoresListe<Producent>();
}
//Get hele kartoteket
public static ProducentKartotek GetProducentKartotek()
{
return producentKartotek;
}
//mulighed for at fjerne en producent.
public void FjerneProducentFraListe(Producent pc)
{
if (producentListe.Contains(pc))
{
producentListe.Remove(pc);
}
}
public void MoveProductFromList(Producent mp)
{
foreach (Producent item in producentListe)
{
if (item == mp)
{
producentListe.Remove(item);
}
}
}
//mulighed for at tilføje en ny producent.
public void TilføjeProducentTilListe(Producent pc)
{
if (!(producentListe.Contains(pc)))
{
this.producentListe.Add(pc);
}
}
//Mulighed for udvidelse af program med en liste af producenter og deres Navn, samt Url.
//Brugt til at teste kravet om Url.
public override string ToString()
{
string resultat;
StringBuilder builder = new StringBuilder();
foreach (Producent pc in this.producentListe)
{
builder.Append(pc).Append(" ");
}
resultat = builder.ToString();
return "\n ProducentKartotek:" +
"\n----------------------------------------------------------------------------------" + resultat
+ "\n-----------------------------------------------------------------------------------";
}
// Another print method
public void PrintProduct()
{
string stResult = " Producent kartotek " + "\n-----------------------------------------------------";
foreach (Producent item in producentListe)
{
Console.WriteLine(stResult+ "\n" + item);
}
}
}
}