Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Bato
- {
- abstract class Product
- {
- public string Name { get; set; }
- public string Creator { get; set; }
- public double Price { get; set; }
- public double Discount { get; set; }
- public Product(string Name, string Creator, double Price, double Discount)
- {
- this.Name = Name;
- this.Creator = Creator;
- this.Price = Price;
- this.Discount = Discount;
- }
- public abstract double GetPrice();
- }
- class Food : Product
- {
- public int ExpirationTime { get; set; }
- public DateTime PackingDate { get; set; }
- public Food(string Name, string Creator, double Price, double Discount, int ExpirationTime, DateTime PackingDate) : base(Name, Creator, Price, Discount)
- {
- this.ExpirationTime = ExpirationTime;
- this.PackingDate = PackingDate;
- }
- public override double GetPrice()
- {
- if(PackingDate.Day - DateTime.Today.Day < 3)
- {
- return Price * (Discount / 100.0);
- }
- else
- {
- return Price;
- }
- }
- }
- class Chemical : Product
- {
- public string Type { get; set; }
- public Chemical(string Name, string Creator, double Price, double Discount, string Type) : base(Name, Creator, Price, Discount)
- {
- this.Type = Type;
- }
- public override double GetPrice()
- {
- if(DateTime.Today.Day % 2 == 0)
- {
- return Price * (Discount / 100.0);
- }
- else
- {
- return Price;
- }
- }
- }
- class Tools : Product
- {
- public double Weight { get; set; }
- public string UsableSeason { get; set; }
- public Tools(string Name, string Creator, double Price, double Discount, double Weight, string UsableSeason) : base(Name, Creator, Price, Discount)
- {
- this.Weight = Weight;
- this.UsableSeason = UsableSeason;
- }
- public override double GetPrice()
- {
- string thisSeason = "";
- int thisMonth = DateTime.Today.Month;
- if (thisMonth >= 3 && thisMonth <= 5)
- {
- thisSeason = "весна";
- }
- else if (thisMonth >= 6 && thisMonth <= 8)
- {
- thisSeason = "лето";
- }
- else if (thisMonth >= 9 && thisMonth <= 11)
- {
- thisSeason = "осень";
- }
- else
- {
- thisSeason = "зима";
- }
- if(thisSeason != UsableSeason)
- {
- return Price * (Discount / 100.0);
- }
- else
- {
- return Price;
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment