Laitofai

Батоха

Apr 22nd, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.20 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 Bato
  8. {
  9.     abstract class Product
  10.     {
  11.         public string Name { get; set; }
  12.         public string Creator { get; set; }
  13.         public double Price { get; set; }
  14.         public double Discount { get; set; }
  15.  
  16.         public Product(string Name, string Creator, double Price, double Discount)
  17.         {
  18.             this.Name = Name;
  19.             this.Creator = Creator;
  20.             this.Price = Price;
  21.             this.Discount = Discount;
  22.         }
  23.  
  24.         public abstract double GetPrice();
  25.     }
  26.  
  27.     class Food : Product
  28.     {
  29.         public int ExpirationTime { get; set; }
  30.         public DateTime PackingDate { get; set; }
  31.        
  32.         public Food(string Name, string Creator, double Price, double Discount, int ExpirationTime, DateTime PackingDate) : base(Name, Creator, Price, Discount)
  33.         {
  34.             this.ExpirationTime = ExpirationTime;
  35.             this.PackingDate = PackingDate;
  36.         }
  37.  
  38.         public override double GetPrice()
  39.         {
  40.             if(PackingDate.Day - DateTime.Today.Day < 3)
  41.             {
  42.                 return Price * (Discount / 100.0);
  43.             }
  44.             else
  45.             {
  46.                 return Price;
  47.             }
  48.         }
  49.     }
  50.  
  51.     class Chemical : Product
  52.     {
  53.         public string Type { get; set; }
  54.  
  55.         public Chemical(string Name, string Creator, double Price, double Discount, string Type) : base(Name, Creator, Price, Discount)
  56.         {
  57.             this.Type = Type;
  58.         }
  59.  
  60.         public override double GetPrice()
  61.         {
  62.             if(DateTime.Today.Day % 2 == 0)
  63.             {
  64.                 return Price * (Discount / 100.0);
  65.             }
  66.             else
  67.             {
  68.                 return Price;
  69.             }
  70.         }
  71.     }
  72.  
  73.     class Tools : Product
  74.     {
  75.         public double Weight { get; set; }
  76.         public string UsableSeason { get; set; }
  77.  
  78.         public Tools(string Name, string Creator, double Price, double Discount, double Weight, string UsableSeason) : base(Name, Creator, Price, Discount)
  79.         {
  80.             this.Weight = Weight;
  81.             this.UsableSeason = UsableSeason;
  82.         }
  83.  
  84.         public override double GetPrice()
  85.         {
  86.             string thisSeason = "";
  87.             int thisMonth = DateTime.Today.Month;
  88.             if (thisMonth >= 3 && thisMonth <= 5)
  89.             {
  90.                 thisSeason = "весна";
  91.             }
  92.             else if (thisMonth >= 6 && thisMonth <= 8)
  93.             {
  94.                 thisSeason = "лето";
  95.             }
  96.             else if (thisMonth >= 9 && thisMonth <= 11)
  97.             {
  98.                 thisSeason = "осень";
  99.             }
  100.             else
  101.             {
  102.                 thisSeason = "зима";
  103.             }
  104.  
  105.             if(thisSeason != UsableSeason)
  106.             {
  107.                 return Price * (Discount / 100.0);
  108.             }
  109.             else
  110.             {
  111.                 return Price;
  112.             }
  113.         }
  114.     }
  115.  
  116.     class Program
  117.     {
  118.         static void Main(string[] args)
  119.         {
  120.            
  121.         }
  122.     }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment