Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.45 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApplication1
  4. {
  5.     public class Puzzle
  6.     {
  7.         private string _Nazwa;
  8.  
  9.         public Puzzle(string nazwa, int iloscElementow, int wiek, float cena)
  10.         {
  11.             _Nazwa = nazwa;
  12.             _IloscElementow = iloscElementow;
  13.             _Wiek = wiek;
  14.             _Cena = cena;
  15.         }
  16.  
  17.         public string Nazwa => _Nazwa;
  18.  
  19.         private int _IloscElementow;
  20.  
  21.         public int IloscElementow
  22.         {
  23.             get => _IloscElementow;
  24.             set
  25.             {
  26.                 _IloscElementow = 100;
  27.                 _IloscElementow = 500;
  28.                 _IloscElementow = 1000;
  29.                 _IloscElementow = 1500;
  30.                 _IloscElementow = 2000;
  31.             }
  32.         }
  33.  
  34.         private int _Wiek;
  35.  
  36.         public int Wiek
  37.         {
  38.             get => _Wiek;
  39.             set
  40.             {
  41.                 if (value < 0 || value > 100)
  42.                 {
  43.                     Console.WriteLine("wiek nie moze byc mniejszy od 0 i wiekszy od 100");
  44.                 }
  45.  
  46.                 _Wiek = value;
  47.             }
  48.         }
  49.  
  50.         private float _Cena;
  51.  
  52.         public float Cena
  53.         {
  54.             get => _Cena;
  55.             set
  56.             {
  57.                 if (value < _Cena)
  58.                 {
  59.                     Console.WriteLine("cena nie moze byc ujemna ");
  60.                 }
  61.  
  62.                 _Cena = value;
  63.             }
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement