Constructor

This commit is contained in:
Geir Okkenhaug Jerstad 2024-12-02 12:45:04 +01:00
parent 96c1b52110
commit 250764b7ef
2 changed files with 14 additions and 12 deletions

View file

@ -2,10 +2,16 @@ namespace StaticogIkkestatic;
public class Places
{
public string PlaceName;
public string Municipality;
public string Region;
public string PlaceName { get; private set; }
public string Municipality{ get; private set; }
public string Region{ get; private set; }
public Places(string placeName, string municipality, string region)
{
PlaceName = placeName;
Municipality = municipality;
Region = region;
}
public void ShowPlace()
{
var labelWidth = 8;

View file

@ -4,15 +4,11 @@
{
static void Main(string[] args)
{
var place = new Places();
place.PlaceName = "Stavern";
place.Municipality = "Larvik";
place.Region = "Vestfold";
var place = new Places( "Stavern","Larvik", "Vestfold");
var place2 = new Places("Rjukan","Tinn","Telemark");
place.ShowPlace();
var place2 = new Places();
place2.PlaceName = "Rjukan";
place2.Municipality = "Tinn";
place2.Region = "Telemark";
place2.ShowPlace();
}