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 class Places
{ {
public string PlaceName; public string PlaceName { get; private set; }
public string Municipality; public string Municipality{ get; private set; }
public string Region; public string Region{ get; private set; }
public Places(string placeName, string municipality, string region)
{
PlaceName = placeName;
Municipality = municipality;
Region = region;
}
public void ShowPlace() public void ShowPlace()
{ {
var labelWidth = 8; var labelWidth = 8;

View file

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