Advertisement
kasper_k

testtask

Dec 20th, 2022
666
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.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 Task
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             DGift certificate = new DGift();
  14.             certificate.Color = "green";
  15.             certificate.Weight = 0.1;
  16.             Console.WriteLine(certificate.ToString());
  17.             ZGift broken_toy = new ZGift();
  18.             broken_toy.Color = "white";
  19.             broken_toy.Weight = 0.7;
  20.             Console.WriteLine(broken_toy.ToString());
  21.             Console.ReadKey();
  22.         }
  23.     }
  24. }
  25. using System;
  26. using System.Collections.Generic;
  27. using System.Linq;
  28. using System.Text;
  29. using System.Threading.Tasks;
  30.  
  31. namespace Task
  32. {
  33.     interface IAboutGift
  34.     {
  35.         string ToString();
  36.     }
  37. }
  38.  
  39. using System;
  40. using System.Collections.Generic;
  41. using System.Linq;
  42. using System.Text;
  43. using System.Threading.Tasks;
  44.  
  45. namespace Task
  46. {
  47.     class DGift: IAboutGift
  48.     {
  49.         private double weight; // kg
  50.         private string color;
  51.         public double Weight
  52.         {
  53.             get => this.weight;
  54.             set => this.weight = value;
  55.         }
  56.         public string Color
  57.         {
  58.             get => this.color;
  59.             set => this.color = value;
  60.         }
  61.         public override string ToString()
  62.         {
  63.             return $"Это добрый подарок! Его вес - {weight}, а его цвет - {color}";
  64.         }
  65.     }
  66. }
  67. using System;
  68. using System.Collections.Generic;
  69. using System.Linq;
  70. using System.Text;
  71. using System.Threading.Tasks;
  72.  
  73. namespace Task
  74. {
  75.     class ZGift: IAboutGift
  76.     {
  77.         private double weight; // kg
  78.         private string color;
  79.         public double Weight
  80.         {
  81.             get => this.weight;
  82.             set => this.weight = value;
  83.         }
  84.         public string Color
  85.         {
  86.             get => this.color;
  87.             set => this.color = value;
  88.         }
  89.         public override string ToString()
  90.         {
  91.             return $"Это злой подарок! Его вес - {weight}, а его цвет - {color}";
  92.         }
  93.     }
  94. }
  95.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement