Advertisement
AskTomorrow

Untitled

Feb 12th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Ismatov_Nozimzhon
  8. {
  9.     class Food : Item
  10.     {
  11.         public Food(string name, double cost, double price) : base(name, cost, price)
  12.         {
  13.         }
  14.  
  15.         private int expDay;
  16.  
  17.         public int ExpDay
  18.         {
  19.             get { return expDay; }
  20.             private set { expDay = value; }
  21.         }
  22.            
  23.         public double GetCurrentPrice(int currentDay)
  24.         {
  25.             if (ExpDay - currentDay >= 5)
  26.             {
  27.                 return this.Price;
  28.             }
  29.             else
  30.             if (ExpDay - currentDay >= 1 && ExpDay - currentDay <= 4)
  31.             {
  32.                 return this.Price * 0.6d;
  33.             }
  34.             else
  35.             if (currentDay == ExpDay)
  36.             {
  37.                 return this.Price * 0.1d;
  38.             }
  39.             else
  40.             {
  41.                 return 0;
  42.             }
  43.         }
  44.  
  45.         public override string ToString()
  46.         {
  47.             return $@"Food {Name} : (ExpDay: {ExpDay}) Price = {Price:F2}, Cost = {Cost:F2}";
  48.         }
  49.  
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement