Created
July 18, 2014 23:31
-
-
Save vilterp/d92fe0734a21cc19f549 to your computer and use it in GitHub Desktop.
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
// Java | |
class Point { | |
int x; | |
int y; | |
public Point(int x, int y) { | |
x | |
} | |
public float distanceTo(Point other) { | |
this.x | |
this.y | |
} | |
} | |
Point myPoint = new Point(x, y); | |
myPoint.distanceTo(otherPoint) | |
// C | |
struct point { | |
int x; | |
int y; | |
} | |
point* new_point(int x, int y) { | |
point *the_new_point = malloc(sizeof(point)) | |
the_new_point.x = x; | |
the_new_point.y = y; | |
return the_new_point; | |
} | |
float distance_to(point* a, point* b) { | |
} | |
// Java | |
interface Shape { | |
float area(); | |
Shape intersection(Shape other); | |
} | |
class Circle implements Shape { | |
float radius; | |
// constructor ... | |
float area() { | |
return Math.pi * Math.pow(radius, 2); | |
} | |
} | |
class Rectangle implements Shape { | |
float length; | |
float width; | |
// constructor... | |
float area() { | |
return length * width; | |
} | |
} | |
Shape some_shape = // .. get from somewhere | |
some_shape.area() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment