Hello, good morning, I already did a search for that same error in this forum, it gave me 2 results... although from what I saw they suggest changing the variable to public and that would solve the error, but from what I understand this would be violate OOP principles.
So how can I solve it? I read on stack that it can be like this:
"This is usually solved using InternalsVisibleToAttribute."
But how correct is this? Thanks.
So how can I solve it? I read on stack that it can be like this:
"This is usually solved using InternalsVisibleToAttribute."
But how correct is this? Thanks.
C#:
amespace Ejemplo1
{
class Botella
{
private int capacidad;
private string color;
private string material;
private int cantidadActual;
// EN VEZ DE USAR G USAMOS ALGO ESPECIAL DE C# LLAMADO PROPIEDAD
public Botella( string color, string material)
{
this.color = color;
this.material = material;
this.capacidad = 100; // por que aca no pone this?
cantidadActual = 0;
}
public string Material // PROPERTY
{
get { return material; }
}
public int Capacidad
{
get { return capacidad; }
}
// PROPIEDAD SOL ODE LECTURA
public int CantidadActual
{
get { return cantidadActual; }
}
public float recargar() //METODO RECARGA
{
if ( cantidadActual>0)
{
int dif = 100 - cantidadActual;
//dif 100------50
// dif ----- dif*50/100
float monto = dif * 50 / 100;
cantidadActual += dif;
return monto;
}
cantidadActual = 100;
return 50;
}
//public int Capacidad // PROPERTY
//{
// get { return capacidad; }
// set { capacidad = value; }
//}
}
}