How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Ingo U Your Own Question

Ingo U
Ingo U, Software Engineer
Category: Homework
Satisfied Customers: 755
Experience:  Over 25 years experience in software development. Expert in Microsoft .Net, C#, C++, VB, SQL
44076068
Type Your Homework Question Here...
Ingo U is online now
A new question is answered every 9 seconds

Please help me with this: Write a Calculator class that

Customer Question

Please help me with this :
Write a Calculator class that matches this specification
describe( "Calculator", function(){
var calculator;
beforeEach( function(){
calculator = new Calculator();
} );
it( "adds 1 and 2", function(){
expect( calculator.add( 1, 2 ) ).to.equal( 3 );
} );
it( "subtracts 2 from 9", function(){
expect( calculator.subtract( 9, 2 ) ).to.equal( 7 );
} );
it( "multiplies 4 and 3", function(){
expect( calculator.multiply( 4, 3 ) ).to.equal( 12 );
} );
it( "divides 10 by 2", function(){
expect( calculator.divide( 10, 2 ) ).to.equal( 5 );
} );
it( "does not divide by 0", function(){
expect( calculator.divide( 5, 0 ) ).to.equal( NaN );
} ); } );
Submitted: 8 months ago.
Category: Homework
Expert:  Ingo U replied 8 months ago.

Hi,

so this looks like JavaScript being tested with Jasmine?
I don't have Jasmine, but I can guess from looking at it what the Calculator class is supposed to do.

Shall I give it a try?

Customer: replied 8 months ago.
please
Customer: replied 8 months ago.
Can i get my answer now please ?
Expert:  Ingo U replied 8 months ago.

Writing code takes a little time. Thank you for your patience.

Expert:  Ingo U replied 8 months ago.

OK, please have a look and give it a try:

http://dl.dropbox.com/u/7895834/calc.js?dl=0

Customer: replied 8 months ago.
Can u please send me a word/notepad doc with the code.
Expert:  Ingo U replied 8 months ago.

How's this?

Customer: replied 8 months ago.
i can see now. is this a class ? how should i define it ?
Expert:  Ingo U replied 8 months ago.

Well, the code I gave you defines the class Calculator. I don't know how it is supposed to "plug in" to your testing framework...

In a regular HTML document, you'd include it with a script node, using the src="calc.js" tag.

Customer: replied 8 months ago.
Hmm..let me try, am little confused. How about this one ?If i were to write a class for below specs :
describe( "ScientificCalculator", function(){
var calculator;
beforeEach( function(){
calculator = new ScientificCalculator();
} );
it( "extends Calculator", function(){
expect( calculator ).to.be.instanceOf( Calculator );
expect( calculator ).to.be.instanceOf( ScientificCalculator );
} );
it( "returns the sine of PI / 2", function(){
expect( calculator.sin( Math.PI / 2 ) ).to.equal( 1 );
} );
it( "returns the cosine of PI", function(){
expect( calculator.cos( Math.PI ) ).to.equal( -1 );
} );
it( "returns the tangent of 0", function(){
expect( calculator.tan( 0 ) ).to.equal( 0 );
} );
it( "returns the logarithm of 1", function(){
expect( calculator.log( 1 ) ).to.equal( 0 );
} );
} );
Expert:  Ingo U replied 8 months ago.

I've posted a quote for the additional work for your consideration.

Expert:  Ingo U replied 8 months ago.

Hi,
just following up, were you able to use my solution?
Please feel free to post any additional questions, comments or concerns you may have regarding this issue.

If you're not yet satisfied with the result, please let me know what is missing.
I will do my best to make it right for you.

Otherwise, please don't forget to rate my service - I don't get paid for my work until your rating is received.

Regards,
Ingo U

Expert:  Ingo U replied 8 months ago.

Hi,
just following up, were you able to use my solution?
Please feel free to post any additional questions, comments or concerns you may have regarding this issue.

If you're not yet satisfied with the result, please let me know what is missing.
I will do my best to make it right for you.

Otherwise, please don't forget to rate my service - I don't get paid for my work until your rating is received.

Regards,
Ingo U

Expert:  Ingo U replied 8 months ago.

Hi,
just following up, were you able to use my solution?
Please feel free to post any additional questions, comments or concerns you may have regarding this issue.

If you're not yet satisfied with the result, please let me know what is missing.
I will do my best to make it right for you.

Otherwise, please don't forget to rate my service - I don't get paid for my work until your rating is received.

Regards,
Ingo U

Expert:  Ingo U replied 8 months ago.
THIS ANSWER IS LOCKED!

You need to spend $3 to view this post. Add Funds to your account and buy credits.