Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace Arrays
- {
- class Person
- {
- //полета -> характеристики
- private string firstName;
- private string lastName;
- private int age;
- private double salary;
- public Person ()
- {
- }
- public string FirstName
- {
- get { return this.firstName; }
- set
- {
- if (value.Length < 3)
- {
- throw new ArgumentException("Name must be over 3 characters");
- }
- this.firstName = value;
- }
- }
- public string LastName
- {
- get { return this.lastName; }
- set
- {
- if (value.Length < 3)
- {
- throw new ArgumentException("Name must be over 3 characters!");
- }
- this.lastName = value;
- }
- }
- public int Age
- {
- get { return this.age; }
- set
- {
- if(value <= 0)
- {
- throw new ArgumentException("Age cannot be negative number!");
- }
- this.age = value;
- }
- }
- public double Salary
- {
- get { return this.salary; }
- set
- {
- if (value < 460)
- {
- throw new ArgumentException("Salary has to be over 460!");
- }
- this.salary = value;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment