Guest User

Untitled

a guest
Mar 17th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 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 ConsoleReadInvitations
  8. {
  9. public class Politician
  10. {
  11. public string LastName { get; set; }
  12. public string FirstName { get; set; }
  13. public string Gender { get; set; }
  14. public string Title { get; set; }
  15. public string Party { get; set; }
  16. public string Salutation { get; set; }
  17.  
  18. public Politician(string line)
  19. {
  20. string name = line.Substring(0, 20).Trim();
  21. int position = name.IndexOf(",");
  22.  
  23. this.LastName = name.Substring(0, position);
  24. this.FirstName = name.Substring(position + 2);
  25. this.Gender = line.Substring(20, 1);
  26. this.Title = this.Gender == "M" ? "Mr." : "Ms.";
  27. this.Party = line.Substring(28);
  28. this.Salutation = String.Format($"Dear {Title} {FirstName} {LastName} of the {Party} party:");
  29. }
  30. }
  31. }
Add Comment
Please, Sign In to add comment