Advertisement
bartigames

figura

Mar 4th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 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 cszrmp
  8. {
  9.     class figura
  10.     {
  11.         protected int wysokosc;
  12.         protected int szerokosc;
  13.         protected Random r = new Random();
  14.         public int wys
  15.         {
  16.  
  17.             set
  18.             {
  19.                 if (value >= 0)
  20.                     szerokosc = value;
  21.                 else
  22.                     wysokosc = 0;
  23.  
  24.             }
  25.             get { return wysokosc; }
  26.         }
  27.         public int szer
  28.         {
  29.        
  30.             set
  31.             {
  32.                 if (value >= 0)
  33.                 szerokosc = value;    
  34.                
  35.                 else
  36.                     szerokosc = 0;
  37.             }
  38.             get { return szerokosc;}
  39.  
  40.          }
  41.         public figura(int szer, int wys)
  42.         {
  43.             szerokosc = szer;
  44.             wysokosc = wys;
  45.  
  46.         }
  47.         public figura()
  48.         {
  49.             szerokosc = r.Next(1, 10);
  50.             wysokosc = r.Next(1, 10);
  51.  
  52.         }
  53.         public virtual float pole()
  54.         {
  55.  
  56.             return wys * szerokosc;
  57.  
  58.         }
  59.         public virtual int obwod()
  60.         {
  61.  
  62.             return 2* szerokosc + 2 * wysokosc;
  63.         }
  64.   }  
  65.     class Program
  66.     {
  67.         static void Main(string[] args)
  68.         {
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement