abstract class Vehicle
{
public string color { get; set; }
public int year { get; set; }
}
abstract class Vehicle
{
protected string color { get; set; }
protected int year { get; set; }
public string Color
{
get { return [Link]; }
set { [Link] = value; }
}
class Car : Vehicle
{
public Car() { } // empty constructor
public Car( string c, int y) // constructor
{
[Link] = c;
[Link] = y;
}
}
class Program
{
static void Main(string[] args)
{
Car bmw = new Car(Red, 2005);
}
}
abstract class Vehicle
{
protected string color;
protected int year;
<
public string Year
{
get { return [Link]; }
set { [Link] = value; }
}
}
class Car : Vehicle
{
}
class Program
{
static void Main(string[] args)
{
Car bmw = new Car();
[Link] = Red;
[Link] = 2005;
Public = Can be called from anywhere.
Protected = Can be called only inside and from child classes.
Private = Can be called only inside a class = Encapsulation.
}
}
Static = Can be called without instantiation.
no Static = Needs to be instantiated before calling.
public string getColor()
{
return [Link];
}
public void setColor(string c)
{
[Link] = c;
}
<
public int getYear()
{
return [Link];
}
public void setYear(string y)
{
[Link] = y;
}
}
class Car : Vehicle
{
}
class Program
{
static void Main(string[] args)
{
Car bmw = new Car();
Void = Does something. Returns nothing.
int, string, oat, double, bool, Car = Does something and returns a value of selected type.
Virtual = The method is declared in the abstract class for inheritance. Can be overridden in a child class.
Override = Overrides the parent method.
[Link](Red);
[Link](2005);
}
}