Ik weet niet of ik al te laat ben:
Maar zou je een snippet van je code kunnen laten zien?
Tuurlijk, dit zijn de methodes
/// <summary>
/// Deze functie berekent of een locatie al dan niet vol is
/// Als het aantal opgetelde containers gelijk is aantalloc(20)
/// dan is de Lane vol.
/// </summary>
/// <returns>true or false</returns>
public bool IsFull()
{
return _myLocations.Count == AantalLoc;
}
public void LocAdd(Location l)
{
if (IsFull())
{
throw new TooManyContainersInLocationException();
}
//een cont kan pas toegevoegd worden aan een locatie in een lane als het gewicht niet hoger is dan toegelaten in de loc.
if (CurrentWeightInLaneKg + l.CurrentWeightInLocationKg > _maxWeightLane)
{
throw new WeightLimitExceededInLocationException();
}
this.MyLocations.Add(l);
}
/// <summary>
/// Deze functie voegt een container toe als aan de volgende voorwaarden voldaan wordt:
/// 1)het maximum gewicht in de locatie niet bereikt is
/// 2)of de locatie niet vol is adhv de functie IsFull die hier wordt opgeroepen
/// Als aan deze voorwaarden niet voldaan wordt dan krijgt men een boodschap te zien
/// </summary>
/// <param name="location">het toevoegen van een container in een locatie op een Lane</param>
public void ContAdd(Container c)
{
if (IsFull())
{
throw new TooManyContainersInLocationException();
}
if (CurrentWeightInLaneKg + c.ContWeightKg >
_maxWeightLane)
{
throw new WeightLimitExceededInLocationException();
}
this._myLocations.Add(c);
}
/// <summary>
/// Functie om containers toe te voegen met 2 parameters (locatie en container)
/// Deze functie voegt een container toe als aan de volgende voorwaarden voldaan wordt:
/// 1)het maximum gewicht in de locatie niet bereikt is
/// 2)of de locatie niet vol is adhv de functie IsFull die hier wordt opgeroepen
/// Als aan deze voorwaarden niet voldaan wordt dan krijgt men een boodschap te zien.
/// </summary>
/// <param name="l">locatie van het type Location</param>
/// <param name="c">container van het type Container</param>
public void ContAdd(Location l,Container c)
{
if (IsFull())
{
throw new TooManyContainersInLocationException();
}
if (CurrentWeightInLaneKg + (l.LocMaxWeightKg + c.ContWeightKg) >
_maxWeightLane)
{
throw new WeightLimitExceededInLocationException();
}
//_myLocations.Add(l.MijnContainers.Add(c));
l.MijnContainers.Add(c);
}
Dit is de Main method waar ik de objecten aanmaak en toon in de console applicatie:
public static void Main()
{
Container c1 = new Container(0, "Rommel", DateTime.Now, 1000.0, "Vuilbak", "CVO");
Container c2 = new Container(0, "Electronische apparaten", DateTime.Now, 1000, "Hong Kong", "Chung");
Container c3 = new Container(0, "Meubelen", DateTime.Now, 1000, "Zweden", "IKEA");
Container c4 = new Container(0, "Toys", DateTime.Now, 4000, "Nederland", "Bart Smit");
Container c5 = new Container(0, "Books", DateTime.Now, 1000, "England", "De Standaard Uitgeverij");
Container c6 = new Container(0, "Fietsen", DateTime.Now, 2000, "Duitsland", "Gazelle");
Location l1 = new Location(3, 1, 5000);
Location l2 = new Location(3, 2, 5000);
Location l3 = new Location(3, 3, 5000);
Lane lane1 = new Lane(100000, 1, 20);
Terminals t = new Terminals(500000);
l1.ContAdd(c1);
l1.ContAdd(c2);
l1.ContAdd(c3);
l2.ContAdd(c4);
l2.ContAdd(c5);
l1.ContRemove(1);
l3.ContAdd(c6);
//lane1.ContAdd(c1);
//lane1.LocAdd(l1);
//lane1.ContAdd(l1, c2);
//lane1.ContAdd(l1, c1);
//Hier vraag ik aan Lane om in elke locatie te kijken welke containers er staan en print die op het scherm
foreach (Location l in lane1.MyLocations)
{
foreach (Container c in l.MijnContainers)
{
Console.WriteLine("---------------------------------------------------------------------");
Console.WriteLine(c);
}
}
Console.WriteLine(lane1);
Console.ReadLine();
//Hier vraag ik om het aantal containers dat in een lane zit op het scherm te tonen.
Console.WriteLine("---------------------------------------------------------------------");
Console.WriteLine("The nbr of containers in lane is: " + lane1.GetNrOfContainers());
Console.ReadLine();
}
Bedankt alvast om hier effe naar te kijken
