Keeping it simple:
using System;
class City {
private string name, state;
private long population;
public City(string name, string state, long population)
{
this.name = name;
this.state = state;
this.population = population;
}
public void relocate(string name, string state, long population)
{
this.name = name;
this.state = state;
this.population = population;
}
public string getString()
{
return name + ", " + state + " Population: " + population;
}
}
class main {
public static void Main()
{
City myCity = new City("Stafford", "VA", 92000);
Console.WriteLine("I was born in " + myCity.getString());
myCity.relocate("Athens", "GA", 100000);
Console.WriteLine("Now I live in " + myCity.getString());
Console.ReadKey(); // Pause
}
} Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401