public int Speed
{
get
{
return CurrentSpeed + CarAcceleration;
{
}
public int CarAcceleration{
get
{
if(Speed >= MaxSpeed)
{
return MaxSpeed
}
return Speed;
}
set;
}
I guess you can roll up the calculations to avoid repeating the summations in multiple places.
I recommend avoiding premature optimization. Based on your example it doesn't seem like performance will be much of an issue. Are you actually seeing performance problems?