mirror of
https://github.com/DanilaFe/abacus
synced 2024-12-23 16:00:09 -08:00
Add new comments.
This commit is contained in:
parent
90a0fa2dc7
commit
2381c93fb5
|
@ -146,6 +146,9 @@ public class AbacusController implements PluginListener {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* The thread in which the computation runs.
|
||||||
|
*/
|
||||||
private Thread calculationThread;
|
private Thread calculationThread;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
package org.nwapw.abacus.number;
|
package org.nwapw.abacus.number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception thrown when the computation is interrupted by
|
||||||
|
* the user.
|
||||||
|
*/
|
||||||
public class ComputationInterruptedException extends RuntimeException {
|
public class ComputationInterruptedException extends RuntimeException {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new exception of this type.
|
||||||
|
*/
|
||||||
public ComputationInterruptedException(){
|
public ComputationInterruptedException(){
|
||||||
super("Computation interrupted by user.");
|
super("Computation interrupted by user.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,15 @@ public abstract class NumberInterface {
|
||||||
*/
|
*/
|
||||||
protected abstract NumberInterface multiplyInternal(NumberInterface multiplier);
|
protected abstract NumberInterface multiplyInternal(NumberInterface multiplier);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiplies this number by another, returning
|
||||||
|
* a new number instance. Also, checks if the
|
||||||
|
* thread has been interrupted, and if so, throws
|
||||||
|
* an exception.
|
||||||
|
*
|
||||||
|
* @param multiplier the multiplier
|
||||||
|
* @return the result of the multiplication.
|
||||||
|
*/
|
||||||
public final NumberInterface multiply(NumberInterface multiplier){
|
public final NumberInterface multiply(NumberInterface multiplier){
|
||||||
checkInterrupted();
|
checkInterrupted();
|
||||||
return multiplyInternal(multiplier);
|
return multiplyInternal(multiplier);
|
||||||
|
@ -43,6 +52,15 @@ public abstract class NumberInterface {
|
||||||
*/
|
*/
|
||||||
protected abstract NumberInterface divideInternal(NumberInterface divisor);
|
protected abstract NumberInterface divideInternal(NumberInterface divisor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Divides this number by another, returning
|
||||||
|
* a new number instance. Also, checks if the
|
||||||
|
* thread has been interrupted, and if so, throws
|
||||||
|
* an exception.
|
||||||
|
*
|
||||||
|
* @param divisor the divisor
|
||||||
|
* @return the result of the division.
|
||||||
|
*/
|
||||||
public final NumberInterface divide(NumberInterface divisor){
|
public final NumberInterface divide(NumberInterface divisor){
|
||||||
checkInterrupted();
|
checkInterrupted();
|
||||||
return divideInternal(divisor);
|
return divideInternal(divisor);
|
||||||
|
@ -57,6 +75,15 @@ public abstract class NumberInterface {
|
||||||
*/
|
*/
|
||||||
protected abstract NumberInterface addInternal(NumberInterface summand);
|
protected abstract NumberInterface addInternal(NumberInterface summand);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds this number to another, returning
|
||||||
|
* a new number instance. Also, checks if the
|
||||||
|
* thread has been interrupted, and if so, throws
|
||||||
|
* an exception.
|
||||||
|
*
|
||||||
|
* @param summand the summand
|
||||||
|
* @return the result of the summation.
|
||||||
|
*/
|
||||||
public final NumberInterface add(NumberInterface summand){
|
public final NumberInterface add(NumberInterface summand){
|
||||||
checkInterrupted();
|
checkInterrupted();
|
||||||
return addInternal(summand);
|
return addInternal(summand);
|
||||||
|
@ -71,6 +98,15 @@ public abstract class NumberInterface {
|
||||||
*/
|
*/
|
||||||
protected abstract NumberInterface subtractInternal(NumberInterface subtrahend);
|
protected abstract NumberInterface subtractInternal(NumberInterface subtrahend);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subtracts another number from this number,
|
||||||
|
* a new number instance. Also, checks if the
|
||||||
|
* thread has been interrupted, and if so, throws
|
||||||
|
* an exception.
|
||||||
|
*
|
||||||
|
* @param subtrahend the subtrahend.
|
||||||
|
* @return the result of the subtraction.
|
||||||
|
*/
|
||||||
public final NumberInterface subtract(NumberInterface subtrahend){
|
public final NumberInterface subtract(NumberInterface subtrahend){
|
||||||
checkInterrupted();
|
checkInterrupted();
|
||||||
return subtractInternal(subtrahend);
|
return subtractInternal(subtrahend);
|
||||||
|
@ -84,6 +120,15 @@ public abstract class NumberInterface {
|
||||||
*/
|
*/
|
||||||
protected abstract NumberInterface negateInternal();
|
protected abstract NumberInterface negateInternal();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new instance of this number with
|
||||||
|
* the sign flipped. Also, checks if the
|
||||||
|
* thread has been interrupted, and if so, throws
|
||||||
|
* an exception.
|
||||||
|
*
|
||||||
|
* @return the new instance.
|
||||||
|
*/
|
||||||
public final NumberInterface negate(){
|
public final NumberInterface negate(){
|
||||||
checkInterrupted();
|
checkInterrupted();
|
||||||
return negateInternal();
|
return negateInternal();
|
||||||
|
@ -97,6 +142,14 @@ public abstract class NumberInterface {
|
||||||
*/
|
*/
|
||||||
protected abstract NumberInterface intPowInternal(int exponent);
|
protected abstract NumberInterface intPowInternal(int exponent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raises this number to an integer power. Also, checks if the
|
||||||
|
* thread has been interrupted, and if so, throws
|
||||||
|
* an exception.
|
||||||
|
*
|
||||||
|
* @param exponent the exponent to which to take the number.
|
||||||
|
* @return the resulting value.
|
||||||
|
*/
|
||||||
public final NumberInterface intPow(int exponent){
|
public final NumberInterface intPow(int exponent){
|
||||||
checkInterrupted();
|
checkInterrupted();
|
||||||
return intPowInternal(exponent);
|
return intPowInternal(exponent);
|
||||||
|
@ -124,6 +177,13 @@ public abstract class NumberInterface {
|
||||||
*/
|
*/
|
||||||
protected abstract NumberInterface ceilingInternal();
|
protected abstract NumberInterface ceilingInternal();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the least integer greater than or equal to the number.
|
||||||
|
* Also, checks if the thread has been interrupted, and if so, throws
|
||||||
|
* an exception.
|
||||||
|
*
|
||||||
|
* @return the least integer >= the number, if int can hold the value.
|
||||||
|
*/
|
||||||
public final NumberInterface ceiling(){
|
public final NumberInterface ceiling(){
|
||||||
checkInterrupted();
|
checkInterrupted();
|
||||||
return ceilingInternal();
|
return ceilingInternal();
|
||||||
|
@ -136,6 +196,13 @@ public abstract class NumberInterface {
|
||||||
*/
|
*/
|
||||||
protected abstract NumberInterface floorInternal();
|
protected abstract NumberInterface floorInternal();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the greatest integer less than or equal to the number.
|
||||||
|
* Also, checks if the thread has been interrupted, and if so, throws
|
||||||
|
* an exception.
|
||||||
|
*
|
||||||
|
* @return the greatest int >= the number, if int can hold the value.
|
||||||
|
*/
|
||||||
public final NumberInterface floor(){
|
public final NumberInterface floor(){
|
||||||
checkInterrupted();
|
checkInterrupted();
|
||||||
return floorInternal();
|
return floorInternal();
|
||||||
|
@ -148,6 +215,12 @@ public abstract class NumberInterface {
|
||||||
*/
|
*/
|
||||||
protected abstract NumberInterface fractionalPartInternal();
|
protected abstract NumberInterface fractionalPartInternal();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the fractional part of the number.
|
||||||
|
* Also, checks if the thread has been interrupted,
|
||||||
|
* and if so, throws an exception.
|
||||||
|
* @return the fractional part of the number.
|
||||||
|
*/
|
||||||
public final NumberInterface fractionalPart(){
|
public final NumberInterface fractionalPart(){
|
||||||
checkInterrupted();
|
checkInterrupted();
|
||||||
return fractionalPartInternal();
|
return fractionalPartInternal();
|
||||||
|
@ -169,6 +242,14 @@ public abstract class NumberInterface {
|
||||||
*/
|
*/
|
||||||
protected abstract NumberInterface promoteToInternal(Class<? extends NumberInterface> toClass);
|
protected abstract NumberInterface promoteToInternal(Class<? extends NumberInterface> toClass);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Promotes this class to another number class. Also, checks if the
|
||||||
|
* thread has been interrupted, and if so, throws
|
||||||
|
* an exception.
|
||||||
|
*
|
||||||
|
* @param toClass the class to promote to.
|
||||||
|
* @return the resulting new instance.
|
||||||
|
*/
|
||||||
public final NumberInterface promoteTo(Class<? extends NumberInterface> toClass) {
|
public final NumberInterface promoteTo(Class<? extends NumberInterface> toClass) {
|
||||||
checkInterrupted();
|
checkInterrupted();
|
||||||
return promoteToInternal(toClass);
|
return promoteToInternal(toClass);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user