Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace Mankind11b
- {
- public abstract class Human
- {
- private string firstName;
- private string lastName;
- public Human(string firstName, string lastName)
- {
- FirstName = firstName;
- LastName = lastName;
- }
- public string FirstName
- {
- get { return firstName; }
- set {
- if (!Char.IsUpper(value[0])) //!(value[0]>='A' && value[0]<='Z')
- {
- throw new ArgumentException("Expected upper case letter! Argument: firstName");
- }
- if (value.Length < 4)
- {
- throw new ArgumentException("Expected length at least 4 symbols! Argument: firstName");
- }
- firstName = value;
- }
- }
- public string LastName
- {
- get { return lastName; }
- set {
- if (!Char.IsUpper(value[0]))
- {
- throw new ArgumentException("Expected upper case letter! Argument: lastName");
- }
- if(value.Length < 3)
- {
- throw new ArgumentException("Expected length at least 3 symbols! Argument: lastName");
- }
- lastName = value;
- }
- }
- public override string ToString()
- {
- return $"First Name: {FirstName}\nLast Name: {LastName}";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment