Created
August 26, 2011 10:54
-
-
Save Jotschi/1173186 to your computer and use it in GitHub Desktop.
Cube CCP File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Cube.h" | |
Cube::Cube() {} | |
Cube::~Cube() {} | |
void Cube::setSide(double s) { | |
side = s <= 0 ? 1 : s; | |
} | |
double Cube::getSide() { | |
return side; | |
} | |
double Cube::Area() { | |
return 6 * side * side; | |
} | |
double Cube::Volume() { | |
return side * side * side; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef CUBE_H | |
#define CUBE_H | |
class Cube { | |
public: | |
Cube(); | |
~Cube(); | |
void setSide(double s); | |
double getSide(); | |
double Area(); | |
double Volume(); | |
private: | |
double side; | |
}; | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static com.googlecode.javacpp.Loader.load; | |
import com.googlecode.javacpp.Pointer; | |
import com.googlecode.javacpp.annotation.Name; | |
import com.googlecode.javacpp.annotation.Platform; | |
@Platform(include = "Cube.h") | |
public class JavaCube { | |
static { | |
load(); | |
} | |
public JavaCube() { | |
NativeCube cube = new NativeCube(); | |
cube.setSide(9); | |
} | |
@Name("Cube") | |
public static class NativeCube extends Pointer { | |
static { | |
load(); | |
} | |
public NativeCube() { | |
Cube(); | |
} | |
public native void setSide(double s); | |
// this = new std::Cube() | |
private native void Cube(); | |
private native double Area(); | |
private native double getSide(); | |
private native double Volume(); | |
public double getArea() { | |
return this.Area(); | |
} | |
public double getVolume() { | |
return this.Volume(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment