Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
{ { {
public string color { get; set; } protected string color { get; set; } protected string color;
public int year { get; set; } protected int year { get; set; } protected int year;
}
public string Color public string getColor()
class Car : Vehicle { {
{ get { return this.color; } return this.color;
public Car() { } // empty constructor set { this.color = value; } }
}
public Car( string c, int y) // constructor public void setColor(string c)
{ public string Year {
this.color = c; { this.color = c;
this.year = y; get { return this.year; }
< <
}
} set { this.year = value; }
} } public int getYear()
} {
class Program return this.year;
{ class Car : Vehicle }
static void Main(string[] args) {
{ } public void setYear(string y)
Car bmw = new Car(Red, 2005); {
} class Program this.year = y;
} { }
static void Main(string[] args) }
{
Car bmw = new Car(); class Car : Vehicle
{
bmw.Color = Red; }
bmw.Year = 2005;
Public = Can be called from anywhere. } class Program
Protected = Can be called only inside and from child classes. } {
Private = Can be called only inside a class = Encapsulation. static void Main(string[] args)
Static = Can be called without instantiation. {
no Static = Needs to be instantiated before calling. Car bmw = new Car();