List<Rational>rationalList = new ArrayList<>();
Random random = new Random();
Rational rational = new Rational();
//產生原分數集合
for(int i = 0;i < 10;i++){
do{
rational.denominator = random.nextInt(Integer.MAX_VALUE);
rational.numerator = random.nextInt(Integer.MAX_VALUE);
}while(rationalList.contains(rational));
rationalList.add(rational);
}
ListrationalList = new ArrayList<>();
Random random = new Random();
Rational rational;
//產生分數集合
for(int i = 0;i < 10;i++){
do{
int dm = random.nextInt();
int nm = random.nextInt();
rational = new Rational(nm,dm);
}while(rationalList.contains(rational));
rationalList.add(rational);
}
//已解決