Advertisement
Filkolev

Price fix

Dec 27th, 2014
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.42 KB | None | 0 0
  1.  public Computer(string name, List<Component> components)
  2.     {
  3.         this.Name = name;
  4.         this.Components = components;
  5.         this.Price = CalcPrice(components);
  6.     }
  7.  
  8.     private float CalcPrice(List<Component> components)
  9.     {
  10.         float totalPrice = 0;
  11.         foreach (Component component in components)
  12.         {
  13.             totalPrice += component.Price;
  14.         }
  15.  
  16.         return totalPrice;
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement