Code:
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
var nicolasProgrammer = new Programmer(
firstName: "Nícolas",
lastName: "Paiuca Buscarini",
locale: "São Paulo, SP",
dateBirth: new DateTime(2001, 2, 7),
languages: new List<string> { "C#", "TypeScript", "Python" },
databaseSkills: new List<string> { "MySQL", "SQL Server", "Oracle" },
education: new List<string> { "Graduation in Computer Science", "Technical Qualification in Industrial Automation" }
);
Console.WriteLine(nicolasProgrammer.ToString());
}
}
public class Programmer
{
public string FirstName { get; private set; }
public string LastName { get; private set; }
public string Locale { get; private set; }
public DateTime DateBirth { get; private set; }
public List<string> Languages { get; private set; }
public List<string> DatabaseSkills { get; private set; }
public List<string> Education { get; private set; }
public Programmer(
string firstName,
string lastName,
string locale,
DateTime dateBirth,
List<string> languages,
List<string> databaseSkills,
List<string> education)
{
FirstName = firstName;
LastName = lastName;
Locale = locale;
DateBirth = dateBirth;
Languages = languages;
DatabaseSkills = databaseSkills;
Education = education;
}
public string FullName
{
get { return $"{FirstName} {LastName}"; }
}
public int Age
{
get
{
var today = DateTime.Today;
var age = today.Year - DateBirth.Year;
if (DateBirth.Date > today.AddYears(-age)) age--;
return age;
}
}
public override string ToString()
{
return $"Programmer: {FullName},\n" +
$"Location: {Locale},\n" +
$"Birthdate: {DateBirth.ToShortDateString()},\n" +
$"Age: {Age},\n" +
$"Languages: {string.Join(", ", Languages)},\n" +
$"Database Skills: {string.Join(", ", DatabaseSkills)},\n" +
$"Education: {string.Join(", ", Education)}";
}
}
Console Output:
Programmer: Nícolas Paiuca Buscarini,
Location: São Paulo, SP,
Birthdate: 07/02/2001,
Age: 23,
Languages: C#, TypeScript, Python,
Database Skills: MySQL, SQL Server, Oracle,
Education: Graduation in Computer Science, Technical Qualification in Industrial Automation
-
E-mail: nicolasbuscarini@hotmail.com