public void AddDeliverable(Deliverable d) { if (FindDeliverable(d.ID) == null) { myDeliverables.Add(d); } else { throw new Exception("Be aware: nothing is added!!!"); } }
public Deliverable FindHeaviestDeliverable() { if (this.myDeliverables.Count == 0) { throw new Exception("There is no heaviest deliverable in an empty transport!"); } Deliverable heaviest = this.myDeliverables[0]; foreach (Deliverable d in this.myDeliverables) { if (d.Weight >= heaviest.Weight) { heaviest = d; } } return(heaviest); }