Link to home
Start Free TrialLog in
Avatar of ZURINET
ZURINET

asked on

Convert C++ Code to Java

Hallo all
I need to convert the attached code to JAVA

ps; Are there any converter tool/ tutorial /or guildline I can make use of

Thanks in Advance

class L2DTopology : public SOMLTopology
{
private:

	long	myHeight;	//
	long	myWidth;	//

	L2DTopology() {};	//privatized to force proper construction

public:

	L2DTopology(long Height, long Width)
	{
		myHeight = Height;
		myWidth  = Width;
	};

	virtual double LatticeDistance(long CellIndex1, long CellIndex2) const;		

	virtual unsigned long NumberOfCells() const { return (myHeight*myWidth); }	

	virtual ~L2DTopology() {};
};

Open in new window

Avatar of Mick Barry
Mick Barry
Flag of Australia image

you need to convert the base class as well
Java2D already has a heaps of classes you may be able to use instead
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ZURINET
ZURINET

ASKER

Hi CEHJ

Thanks for the input..
Just a question..
If I call the method  
 public /*unsigned*/ long numberOfCells()

{
return (height*width);

}      

where would the height*width come from.. ?
Since the method numberOfCells() does not take any argument
it comes from the member vars provided to the constructor

    private long height;
    private long width;
You're also going to need the SOMLTopology class

And you'll need to subclass L2DTopology to actually use it.
>>You're also going to need the SOMLTopology class

Not necessarily. Only if the whole original hierarchy needs modelling

>>where would the height*width come from.. ?
Since the method numberOfCells() does not take any arguments
>>

height and width are instance variables
Avatar of ZURINET

ASKER

Just one last help

If I have SOMLTopology see below..

If I have the java code.. I can do the rest..

Thanks in Advance


class SOMLTopology

{
public:

	SOMLTopology() {};

	virtual double LatticeDistance(long CellIndex1, long CellIndex2) const =0;
	virtual unsigned long NumberOfCells() const =0;

	virtual ~SOMLTopology() {};
};

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
and your othr class should be:


public abstract class L2DTopology extends SOMLTopology {

you could probably make SOMLTopology an interface actually
Avatar of ZURINET

ASKER

The message const =0;
is not relevant in Java?
>>
The message const =0;
is not relevant in Java?
>>

No - there's no equivalent in Java