This Math Parser is one of the best Math parsers ever created. You can easily understand the structure of this package.

If you have any comments please send to: hussam at kfupm.edu.sa

See documentation to know how to use the package in your software.

This is a utility for mathematics parsing. Version 2.7 Check the latest Version here.

Programmed By Hussam Almulhim

It is easily extendable.

 

You should hava Java 5. please download from www.java.com

Use Ctrl-C and Ctrl-V to Copy and Paste.

To see it in action (Applet) click here

Download Library in Jar Format: click here

Download GUI Executable Jar for Testing: click here

Download Source: click here Version 2.7

To see Documentation: click here

Requires Java 1.5

 

 

 

To start using the package do the following:

 

//import the required packages:

import hussam.math.operations.*;

import hussam.math.operations.parser.*;

import hussam.math.operations.extra.*;

 

public class TestMathParser{

 

    public static void main(String[]args)throws MathException{

        //استخدم الدالة التالية حتى تحصل على قارئ للدوال الرياضية

        //get a reader from the DynamicExpressionReader class, or the ExpressionReader class.

        OperationReader reader = DynamicExpressionReader.getInstance();

 

        //اقرأ الدالة التالية بالطريقة المدونة التالية

        //Read an operation:

        Operation o1= reader.readOperation(" x + 4 * Cos (60)");

        //اطبع ناتج العملية مع ملاحظة أن المتغير يساوي صفرا

        //print the result:

        System.out.println("x=0 Result of operation: "+o1+" = " +o1.result());

 

        //نغير قيمة المتغير المدخل إلى 10

        //change the value of variable x:

        reader.getOperatorSource().getLocalVariable("x").setOperation(new ConstantNumber(10));

        //اطبع الناتج مرة أخرى

        //print the result again:

        System.out.println("x=10 Result of operation: "+o1+" = " +o1.result());

 

    }

}

----------------------------------------------

Describing the code:

 

16-8-1426

The code uses many kinds of design patterns in OOP. For example, the Factory pattern is used in the OperatorFactory interface. The Decorator pattern is used with all operation classes like Variables , Contant, Function, ConstantNumber, Operator, etc. The Proxy Pattern used in the OperationProxy class. Singleton was used in the OperatorFactoryDB class. Moreover, some classes implements many patterns such as OperatorSource classes, they are treated as proxies and decorators at the same time!

 

 

 

Any Problems please email me.

Be sure that you have Java 5.