-
-
Save codecademydev/2aaf97ab8ee6d3576eff5a6c74ee0749 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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