Advertisement
maxlarin2

rubezhka

Mar 31st, 2014
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.32 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication6
  7. {
  8.     class goods
  9.     {
  10.         const int n = 5; // кол-во товаров
  11.         private int i = 0;
  12.         protected string kind, Type, Col;
  13.         protected int money, Size;
  14.         clothes[] list = new clothes[n];
  15.         public goods(string kind, int money, string Type, string Col, int Size)
  16.         {
  17.             foreach (clothes elem in list)
  18.             {
  19.                 if (is_equal(elem, Array.IndexOf(list, elem)))
  20.                 {
  21.                     list[i] = new clothes(kind, money, Type, Col, Size);
  22.                     i++;
  23.                 }
  24.                 else
  25.                     i++;
  26.                
  27.             }
  28.         }
  29.         public clothes addition
  30.         {
  31.            
  32.             set {
  33.                
  34.                 list[i] = new clothes(kind, money, Type, Col, Size); }
  35.         }
  36.         private bool is_equal(clothes elem, int temp)
  37.         {
  38.             int count = 0;
  39.             for (int i = 0; i < temp - 1; i++)
  40.             {
  41.                 for (int j = i + 1; j < temp; j++)
  42.                 {
  43.                     if (list[i] == list[j]) count++;
  44.                 }
  45.             }
  46.             if (count > 1) return true;
  47.             else return false;
  48.         }
  49.         public void read
  50.         {
  51.  
  52.             get
  53.             {
  54.                
  55.                 foreach (clothes elem in list)
  56.                {
  57.                    string s = elem.Info;
  58.                }
  59.             }
  60.         }
  61.     }
  62.     abstract class shop
  63.     {
  64.         protected short price;
  65.         protected string kind;
  66.         public shop(string kind, int money)
  67.         {
  68.             this.kind = kind;
  69.             this.price = (short)money;
  70.         }
  71.         abstract void sold();
  72.         abstract void info();
  73.     }
  74.     class clothes : shop
  75.     {
  76.         protected string type, color;
  77.         protected int size;
  78.         protected bool is_sold;
  79.         public clothes(string kind, int money, string Type, string Col, int Size)
  80.             : base(kind, money)
  81.         {
  82.             this.type = Type;
  83.             this.color = Col;
  84.             this.size = Size;
  85.         }
  86.         public string Color
  87.         {
  88.             get { return color; }
  89.             set
  90.             {
  91.                 if (color != value)
  92.                     color = value;
  93.             }
  94.         }
  95.         public int Price
  96.         {
  97.             get { return price; }
  98.             set
  99.             {
  100.                 if (price != value)
  101.                     price = (short)value;
  102.             }
  103.         }
  104.         public string Type
  105.         {
  106.             get { return type; }
  107.             set
  108.             {
  109.                 if (type != value)
  110.                     type = value;
  111.             }
  112.         }
  113.         override public void sold(int money)
  114.         {
  115.             if (money < price)
  116.             {
  117.                 is_sold = false;
  118.             }
  119.             else is_sold = true;
  120.         }
  121.         public string Info
  122.         {
  123.             get { return Convert.ToString(type) + Convert.ToString(price) + Convert.ToString(color) + Convert.ToString(size); }
  124.         }
  125.     }
  126.  
  127.     class Program
  128.     {
  129.         static void Main(string[] args)
  130.         {
  131.         }
  132.     }
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement