Compact Class For Java – CCMath


Compact Class is a collection of common functions and classes that can make your code more concise, fast, and precise.

utility

Class CCMath

java.lang.Object

extended by

utility.CCMath

public class CCMathextends java.lang.Object

CCMath is a collection of method which is used to calculate or manipulate the
variable or object by using the expression or operation of a string.

Since:
11.03.17
Version:
12.03.17
Author:
Yosua Onesimus


Constructor Detail

CCMath

public CCMath()


Method Detail

calculate

public static java.lang.Double calculate(java.lang.String expression)
Calculate the result of an expression.

 CCMath.calculate("((9+8-7)*6/5)^4")

will produce 20736.0

 

Parameters:
expression – Expression to be calculated.
Returns:
Double The results of a calculation expression.

calculate

public static java.lang.Double calculate(java.lang.String expression,
                                         java.lang.String equality)
Calculate the result of an expression.

 CCMath.calculate(
   "((9+x-7)*y/5)^z",
   "x=8;y=6;z=4;")

will produce 20736.0

 

Parameters:
expression– Expression to be calculated.
equality – Equation that contains the value of a variable.
Returns:
Double The results of a calculation expression.

calculate

public static java.lang.Double calculate(java.lang.String expression,
                                         java.lang.String... equalities)
Calculate the result of an expression.

 CCMath.calculate(
   "((9+x-7)*y/5)^z",
   "x=8",
   "y=6",
   "z=4")

will produce 20736.0

 

Parameters:
expression– Expression to be calculated.
equalities – Equation that contains the value of a variable.
Returns:
Double The results of a calculation expression.

calculate

public static java.lang.Double calculate(java.lang.String expression,
                                         java.util.HashMap<java.lang.String,java.lang.Double> variable_value)
Calculate the result of an expression.

 

Parameters:
expression– Expression to be calculated.
variable_value – HashMap in which there is the variable as its key
and the value of a variable as its value.

 

Returns:Double The results of a calculation expression.


expression

public static java.lang.String expression(java.lang.String expression,
                                          java.lang.Object variable)
Create a new expression by replacing all variables with a value that
corresponds.

 

Parameters:
expression– Expression to be calculated.
variable – object in which there are attributes that serve as
variable.

 

Returns:expression The new expression without variables.


calculate

public static java.lang.Double calculate(java.lang.String expression,
                                         java.lang.Object variable)
Calculate the result of an expression.

 

Parameters:
expression– Expression to be calculated.
variable – object in which there are attributes that serve as
variable.

 

Returns:Double The results of a calculation expression.


manipulate

public static void manipulate(java.lang.Object object,
                              java.lang.String operation)
Manipulate the attributes of an object based on an operation.

 

Parameters:
object– Object whose attributes will be manipulated.
operation – string that contains an operation to manipulate the
attributes of an object.

 


getVariables

public static java.util.List<java.lang.String> getVariables(java.lang.String expression)
Get a variable from an expression.

 

Parameters:
expression – Expression to be searched for the name of the variable.

 

Returns:variables Variables of an expression.


power

public static double power(double... numbers)
 CCMath.power(2, 3, 4)

will produce 4096.0

 

Parameters:
numbers
Returns:
double

times

public static double times(double... numbers)
 CCMath.times(2, 3, 4)

will produce 24.0

 

Parameters:
numbers
Returns:
double

divided

public static double divided(double... numbers)
 CCMath.divided(2, 3, 4)

will produce 0.1667

 

Parameters:
numbers
Returns:
double

plus

public static double plus(double... numbers)
 CCMath.plus(2, 3, 4)

will produce 9.0

 

Parameters:
numbers
Returns:
double

minus

public static double minus(double... numbers)
 CCMath.minus(2, 3, 4)

will produce -5.0

 

Parameters:
numbers
Returns:
double

max

public static double max(double... numbers)
Returns the greater of some double values.

 

Parameters:
numbers – an argument.

 

Returns:double the larger of argument.


min

public static double min(double... numbers)
Returns the smaller of some double values.

 

Parameters:
numbers – an argument.

 

Returns:double the smaller of argument.


round

public static double round(double number,
                           double min)
Returns the biggest min value to the argument.

 

Parameters:
number– a argument
min – minimal value.

 

Returns:the value of the argument rounded to the biggest min value.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: