项目作者: shinylightdev

项目描述 :
Arithmetic problem generator based on parameters. To be used for ditto sheets.
高级语言: TypeScript
项目地址: git://github.com/shinylightdev/math-problems.git
创建时间: 2020-07-24T21:54:12Z
项目社区:https://github.com/shinylightdev/math-problems

开源协议:

下载


Math Problem Generator

Generates random addition and subtraction based on parameters.

Usage

Let’s import the following.

  1. import { Problem } from './models/Problem';
  2. import { Operand } from './models/Operand';

Now let’s add two numbers:

  1. let problem = new Problem(
  2. "+",
  3. [
  4. new Operand(1, 5),
  5. new Operand(4, 6)
  6. ]
  7. );
  1. // Return something like "3+4"
  2. console.log(p.generateExpression());
  3. // Returns 7
  4. console.log(p.getAnswer());
  5. // Returns -1
  6. console.log(p.getSubtraction());
  7. // Returns 7
  8. console.log(p.getSum());

Testing

Currently tests are limited. Uses Jasmine to test.

Installing Jasmine for TypeScript:

  1. # Global Jasmine installation
  2. npm install -g jasmine
  3. # TypeScript Jasmine types
  4. npm install --save @types/jasmine

To run the tests:

  1. npm test

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT