Hej,
piszę program, który dodaje liczby do siebie. Są 2 klasy, jedna public (Program) oraz klasa Dodowanie:
class Dodawanie{
BigInteger wielkaLiczba;
int dodaj (int a, int b){
return a+b;
}
double dodaj(double a, double b){
return a+b;
}
}
public class Program{
public static void main(String args[]){
double a = 5.5;
double b = 2.1;
double result;
Dodawanie Wynik = new Dodawanie();
result = Wynik.dodaj(a,b);
System.out.println(result);
}
}
Ten kod działa dobrze. Jesli zmienię w Classie program typu double na int to dostanę również prawidłowy wynik.
Problem w tym, że chcę przetestować to na classie BigInteger.
Jak to zrobić ?
Moje proby (nie dziala) wygladaja tak:
import java.math.BigInteger;
class Dodawanie{
BigInteger wielkaLiczba;
int dodaj (int a, int b){
return a+b;
}
double dodaj(double a, double b){
return a+b;
}
//wielkaLiczba dodaj(BigInteger wielkaLiczbaa, BigInteger wielkaLiczbab){
//return wielkaLiczbaa.add(wielkaLiczbab);
//}
}
Proszę o pomoc,
Jacek Antek