.
:
[1] ( "getter" (s) "" setter "(s)).
[2] , ?
[1] ( "getter" (s) "" setter "(s)).
Go, " " a.k.a. "getter (s) setter (s)". , , .
[2] , ?
" " , "" , "private" "protected". " ", "" , "" "" .
[1] ( "getter" (s) "" setter "(s)).
Go, " " a.k.a. "getter (s) setter (s)".
, , .
, , , .
" " .
[2] , ?
" " , "" , "private" "protected".
" ", "" , "" "" .
"" accesors, - ,
.
:
public class ControlClass {
protected String controlname;
protected int width;
protected int height;
public final String getControlName()
{
return this.controlname;
}
@Override
public int getWidth()
{
return this.width;
}
@Override
public void setWidth(int newvalue)
{
this.width = newvalue;
}
@Override
public int getHeight()
{
return this.height;
}
@Override
public void setHeight(int newvalue)
{
this.height = newvalue;
}
public ControlClass(){
this.controlname = "control";
this.height = 0;
this.width = 0;
}
}
public class ButtonClass extends ControlClass {
@Override
public int getWidth()
{
if (this.width < 5)
return 5
else
return this.width;
}
@Override
public void setWidth(int newvalue)
{
if (newvalue < 5)
throw new ArithmeticException("integer underflow");
this.width = newvalue;
}
@Override
public int getHeight()
{
if (this.height < 5)
return 5
else
return this.height;
}
@Override
public void setHeight(int newvalue)
{
if (newvalue < 5)
throw new ArithmeticException("integer underflow");
this.height = newvalue;
}
public ControlClass(){
this.controlname = "ButtonClass";
this.height = 5;
this.width = 5;
}
}
"private" , , , , , , "", . .
.
- , "", .
, Object Pascal (a.k.a. "Delphi" ), ECMAScript ( "Javascript" ), ++, #. , Delphi # " ", , Object and Class Oriented Software Application.
Java?
Java ++, , # Delphi, , , , .
.