Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created September 21, 2022 15:42
Show Gist options
  • Save codecademydev/2aaf97ab8ee6d3576eff5a6c74ee0749 to your computer and use it in GitHub Desktop.
Save codecademydev/2aaf97ab8ee6d3576eff5a6c74ee0749 to your computer and use it in GitHub Desktop.
Codecademy export
using System;
namespace DatingProfile
{
class Profile
{
private string name;
private int age;
private string city;
private string country;
private string pronouns;
private string[] hobbies;
public Profile(string name, int age, string city, string country, string pronouns = "they/them")
{
this.name = name;
this.age = age;
this.city = city;
this.country = country;
this.pronouns = pronouns;
}
public string ViewProfile()
{
string hobbies = "";
foreach (string hobbie in this.hobbies) {
hobbies += $"{hobbie}, ";
}
hobbies = hobbies.Remove(hobbies.Length - 2);
return $"Name: {this.name} \nAge: {this.age} \nCity: {this.city} \nCountry: {this.country} \nHobbies: {hobbies}";
}
public void SetHobbies(string[] hobbies)
{
this.hobbies = hobbies;
}
}
}
using System;
namespace DatingProfile
{
class Program
{
static void Main(string[] args)
{
Profile sam = new Profile("Sam Drakkila", 30, "New York", "USA", "he/hom");
sam.SetHobbies(new string[]{"Video games", "Board games"});
Console.WriteLine(sam.ViewProfile());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment