Advertisement
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 Ismatov_Nozimzhon
- {
- class Food : Item
- {
- public Food(string name, double cost, double price) : base(name, cost, price)
- {
- }
- private int expDay;
- public int ExpDay
- {
- get { return expDay; }
- private set { expDay = value; }
- }
- public double GetCurrentPrice(int currentDay)
- {
- if (ExpDay - currentDay >= 5)
- {
- return this.Price;
- }
- else
- if (ExpDay - currentDay >= 1 && ExpDay - currentDay <= 4)
- {
- return this.Price * 0.6d;
- }
- else
- if (currentDay == ExpDay)
- {
- return this.Price * 0.1d;
- }
- else
- {
- return 0;
- }
- }
- public override string ToString()
- {
- return $@"Food {Name} : (ExpDay: {ExpDay}) Price = {Price:F2}, Cost = {Cost:F2}";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement