Advertisement
slawea

Untitled

Sep 17th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. interface IQuantity
  2. {
  3.     void ReturnQuantityLiter();
  4.     void ReturnQuantityKilo();
  5. }
  6.  
  7. abstract class TypeProductsInBag
  8. {
  9.     public abstract void CalculateTypeProductsInBag(int quantity);
  10. }
  11.  
  12. class FruitsInBag:TypeProductsInBag, IQuantity
  13. {
  14.     public int NumberFruitInBag { get; set; }
  15.  
  16.     public override void CalculateTypeProductsInBag(int quantity)
  17.     {
  18.         NumberFruitInBag += quantity;
  19.     }
  20.  
  21.     public void DisplayQuantityKilo()
  22.     {
  23.         //wyświetl ilość kilogramów
  24.     }
  25.  
  26.     //metoda DisplayQuantityLiter nie pasuje więc jest nie używana w tej klasie
  27.     public void DisplayQuantityLiter()
  28.     {
  29.         throw new NotImplementedException();
  30.     }
  31. }
  32.  
  33. class DrinksInBag : TypeProductsInBag, IQuantity
  34. {
  35.     public int NumberDrinksInBag { get; set; }
  36.  
  37.     public override void CalculateTypeProductsInBag(int quantity)
  38.     {
  39.         NumberDrinksInBag += quantity;
  40.     }
  41.  
  42.     public void DisplayQuantityLiter()
  43.     {
  44.         //wyświetl ilość litrów
  45.     }
  46.  
  47.     //metoda DisplayQuantityKilo nie pasuje więc jest nie używana w tej klasie
  48.     public void DisplayQuantityKilo()
  49.     {
  50.         throw new NotImplementedException();
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement