happyElephant

Jan 14, 2007, 03:00 PM

Has anybody heard/used the book"Beginning algorithms" by S.Harris&J.Ross?

What do you think about it? Would you advise it for the very beginner?

I've been trying to get an idea of JUnit test&code it tests: I've created two files(JUnit test&corresponding code-both examples from the textbook) in Net Beans Blue J5.0(Xcode is still quite tough to handle:).

JUnit test results were:"Failed to prepare tests". I wonder why?

Neither I could execute the code because it doesn't have "main "method(I've also unsuccessfully tried to squeeze "main" in):

package com.wrox.algorithms.iteration; // what kind of package is this?

public final class PowerCalculator{

public static final PowerCalculator INSTANCE=new PowerCalculator();

private PowerCalculator(){

}

public int calculate(int base, int exponent){

assert exponent>=0:"exponent can't be<0";

int result=1;

for(int i=0;i<exponent;++i){

result*=base;

}

return result;

}

}

Summarising it all, I have my exams in a week(loads of maths, mecanics, computer architecture, networks(html,php),signal processing...algorithms). As a result, I decided to skip JUnit testing(in our algorithm class they didn't talk about it) for a while & learn some basic functional codes(algorithms) only.

Please, tell me where to add "main" in order to make this "PowerCalculator" function(I'll do the same with other codes(ex.sorting etc.)

P.S.: Sorry, if sometimes it looks that I have no idea what I'm talking about-it could be the case:)

What do you think about it? Would you advise it for the very beginner?

I've been trying to get an idea of JUnit test&code it tests: I've created two files(JUnit test&corresponding code-both examples from the textbook) in Net Beans Blue J5.0(Xcode is still quite tough to handle:).

JUnit test results were:"Failed to prepare tests". I wonder why?

Neither I could execute the code because it doesn't have "main "method(I've also unsuccessfully tried to squeeze "main" in):

package com.wrox.algorithms.iteration; // what kind of package is this?

public final class PowerCalculator{

public static final PowerCalculator INSTANCE=new PowerCalculator();

private PowerCalculator(){

}

public int calculate(int base, int exponent){

assert exponent>=0:"exponent can't be<0";

int result=1;

for(int i=0;i<exponent;++i){

result*=base;

}

return result;

}

}

Summarising it all, I have my exams in a week(loads of maths, mecanics, computer architecture, networks(html,php),signal processing...algorithms). As a result, I decided to skip JUnit testing(in our algorithm class they didn't talk about it) for a while & learn some basic functional codes(algorithms) only.

Please, tell me where to add "main" in order to make this "PowerCalculator" function(I'll do the same with other codes(ex.sorting etc.)

P.S.: Sorry, if sometimes it looks that I have no idea what I'm talking about-it could be the case:)