Code Monkey home page Code Monkey logo

jv-lambda-calc's Introduction

jv-lambda-calc

Write a calculator. Method calculate() should accept three parameters: two values of type double and operation of type char. This method should be able to perform the following operations:

  • Addition
  • Subtraction
  • Division
  • Multiplication
  • raising to a power

In your test class you should cover such test cases:

  • addition with 2 positive operands;
  • addition with 2 negative operands;
  • addition with positive and negative operands;
  • addition with zero in different places;
  • addition for min and max double values;
  • same for subtraction;
  • same for multiplication;
  • same for division (check division by 0);
  • raising positive/negative value to the positive power;
  • raising positive/negative value to the negative power;
  • raising positive/negative value to zero power;
  • raising zero to power;
  • illegal operation;

P.S. Feel free to cover other test cases.

In some cases, you'll have to use delta value in assertEquals for doubles. Difference should be less than DELTA in order for test to pass; For example:

   double expected = 2.0005;
   double actual = 2.00041;
   double delta = 0.0001;
   assertEquals(expected, actual, delta);
//test passed

There are a lot of ways to name your test methods. The main point is that they should have informative names and be consistent along with other developers in your team. For this task use such convention: <methodUnderTest>_<state>_<expectedBehavior>; For example, if we are testing the method calculate with an illegal character passed as an operation the test method name should be calculate_illegalOperation_notOk. notOk is because the test expects the calculate method to throw an exception.

Try to avoid these common mistakes while solving the task

jv-lambda-calc's People

Contributors

dmytro-hryhoruk avatar boroda4436 avatar romandubovskyi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.