Advertisement
n4wn4w

C# demo ot lekcia s building 2 lekcia nakov

Jun 5th, 2015
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.31 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.  
  8.    public class Building
  9.     {
  10.        /*
  11.        /// <summary>
  12.        /// //// poleta
  13.        /// </summary>
  14.        private string address;
  15.        private int floors;
  16.        private double kvadratniMetra;
  17.  
  18.        /// <summary>
  19.        /// ///////////
  20.        /// </summary>
  21.        /// ///////////// property e kogato imame get i set
  22.        public string Addres
  23.        {
  24.            get
  25.            {
  26.                return this.address;
  27.            }
  28.            set
  29.            {
  30.                this.address = value;
  31.            }
  32.        }
  33.       /// <summary>
  34.       /// /////////////////////////////////
  35.       /// </summary>
  36.        public int Floors
  37.        {
  38.            get
  39.            {
  40.                 return this.floors;
  41.            }
  42.        }
  43.        /// <summary>
  44.        /// ////////////////////////////////
  45.        /// </summary>
  46.        public double KvadratniMetra
  47.        {
  48.            get
  49.            {
  50.                return this.kvadratniMetra;
  51.            }
  52.        }
  53.        */
  54.        private string address;
  55.  
  56.        public string Address
  57.        {
  58.            get
  59.            {
  60.                return this.address;
  61.            }
  62.            set
  63.          {
  64.              if (String.IsNullOrEmpty(value))
  65.              {
  66.                  throw new ArgumentException("address cannot be empty.");// ne moje da s e sloji prazen adres
  67.              }
  68.              this.address = value;
  69.          }
  70.        
  71.        }
  72.  
  73.        public int Floors { get; private set; }
  74.  
  75.        public double KvadtratniM { get; private set; }
  76.  
  77.        public readonly double Length;
  78.  
  79.        public const double PI = 3.1415926;
  80.  
  81.        /// <summary>
  82.        /// ///////   konstruktor
  83.        /// </summary>
  84.        /// <param name="address"></param>
  85.        /// <param name="floors"></param>
  86.        /// <param name="kvadratniMetra"></param>
  87.        ///
  88.  
  89.      
  90.  
  91.  
  92.  
  93.        public Building(string address, int floors, double kvadratniMetra)
  94.        {
  95.            this.Address = address;
  96.            this.Floors = floors;
  97.            this.KvadtratniM = kvadratniMetra;
  98.            this.Length = this.Floors * this.KvadtratniM;
  99.          
  100.        }
  101.        /// <summary>
  102.        /// //// drug konstruktor
  103.        /// </summary>
  104.        /// <param name="address"></param>
  105.        ///
  106.  
  107.        public Building(string address) : this(address, 0, 0.0)
  108.        {
  109.  
  110.        }
  111.  
  112.     /*   public Building(string address)
  113.        {
  114.            this.Address = address;
  115.            this.Floors = 0;
  116.            this.KvadtratniM = 0;
  117.        } */
  118.        /// <summary>
  119.        /// ///
  120.        /// </summary>
  121.        /// <param name="address"></param>
  122.      
  123.  
  124.        public override string ToString()
  125.        {
  126.            
  127.            return String.Format("Address: {0}; Floors: {1}; kvadratni Metra: {2}; Length:{3}",
  128.                this.Address, this.Floors, this.KvadtratniM, Length);
  129.        }
  130.            
  131.     }
  132.  
  133.  
  134.    public class PlayWithBuldings
  135.    {
  136.        static void Main(string[] args)
  137.        {
  138.            Building parkHotel = new Building(
  139.                "10 kvartal Iztok",
  140.                5,
  141.                1234.44
  142.                );
  143.  
  144.            Building SoftUni = new Building(
  145.                "15-17 Tintyva",
  146.                3,
  147.                444.55
  148.            );
  149.        
  150.            SoftUni.Address = "nov adres Maika";
  151.  
  152.            Building kvartalPancharevo = new Building("jk.Pancherevo", 0 ,0.0);
  153.  
  154.          //  kvartalPancharevo.Floors = 7;  ne moejm zashtoto floor e - private get;
  155.  
  156.            Console.WriteLine(kvartalPancharevo);
  157.  
  158.          
  159.            Console.WriteLine(parkHotel);
  160.            Console.WriteLine(SoftUni);
  161.  
  162.            DateTime easter = new DateTime(2015, 4, 27, 4, 3, 6);
  163.            DateTime christmas = new DateTime(2015, 12, 25);
  164.  
  165.            Console.WriteLine(easter);
  166.            Console.WriteLine(christmas);
  167.  
  168.        }
  169.    }
  170.  
  171. ////////////////////////////////////////////////////////
  172.  
  173.  
  174. using System;
  175. using System.Collections.Generic;
  176. using System.Linq;
  177. using System.Text;
  178. using System.Threading.Tasks;
  179.  
  180. namespace ConsoleApplication35
  181. {
  182.     class Program
  183.     {
  184.         public class Cat
  185.         {
  186.  
  187.  
  188.             private string name;
  189.             private string owner;
  190.  
  191.             public Cat(string name, string owner)
  192.             {
  193.                 this.Name = name;
  194.                 this.Owner = owner;
  195.             }
  196.  
  197.             public string Name
  198.             {
  199.                 get { return this.name;}
  200.                 set { this.name = value; }
  201.             }
  202.  
  203.             public string Owner
  204.             {
  205.                 get { return this.owner; }
  206.                 set { this.owner = value; }
  207.             }
  208.  
  209.             public void SayMiau()
  210.             {
  211.                 Console.WriteLine("Miauuuuuuuuu");
  212.             }
  213.  
  214.             public override string ToString()
  215.             {
  216.  
  217.                 return String.Format("Name of cat : {0}; sobstvenik : {1}",
  218.                     this.Name, this.Owner
  219.                     );
  220.             }
  221.         }
  222.  
  223.  
  224.         static void Main(string[] args)
  225.         {
  226.  
  227.  
  228.             Cat hoisss = new Cat("kor","hoi");
  229.  
  230.             Console.WriteLine(hoisss);
  231.  
  232.             hoisss.SayMiau();
  233.            
  234.         }
  235.     }
  236. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement