
السلام عليكم
في الحقيقة، تستطيعين أن تصممي class خاصة بـ Factorial مثلاَ و تضيفي الـ methods الخاصة بها فقط مما يقيد عملية التعامل معها، وبالتالي لا داعي أن تصممي لغة جديدة، و إليك مثال سريع
كود:
class Factorial extends Object{
private int i;
private int fV;
public Factorial(){
this(1);
}
public Factorial(int x){
i=x;
computeFact();
}
public int getVal(){ return i; }
public int getFact(){ return fl; }
public void computeFact(){
int x=1;
for(int j=2;j<=i;j++){
x*=j;
}
fV=x;
}
public setVal(int x){
i=x;
computeFact();
}
}