Skip to content

Instantly share code, notes, and snippets.

public interface Shape{
double area();
}
public class Square {
private int topLeftCoordinateX;
private int topLeftCoordinateY;
private int side;
public double area(){
public class Square {
public int topLeftCoordinateX;
public int topLeftCoordinateY;
public int side;
}
public class AreaCalculator{
public double area(Object shape){
if (shape instanceof Square){
Square square = (Square) shape;
import org.junit.Test;
import static org.junit.Assert.*;
public class MovingObjectTest {
@Test
public void testDisplacement(){
MovingObject object = new MovingObject(10, 10, 10, 10);
assertEquals(600, object.displacement(), 0);
}
public class Main {
public static void main(String[] args) {
MovingObject object = new MovingObject(10, 10, 10 );
System.out.println(object.displacement());
System.out.println(object.currentMomentum());
}
}
public class MovingObject {
private int initialVelocity;
private int duration;
private int acceleration;
private int mass;
public MovingObject(int initialVelocity, int duration, int acceleration, int mass) {
this.initialVelocity = initialVelocity;
this.duration = duration;
this.acceleration = acceleration;
public class Main {
public static void main(String[] args) {
MovingObject object = new MovingObject(10, 10, 10 );
System.out.println(object.displacement());
}
}
public class MovingObject {
private int initialVelocity;
private int duration;
private int acceleration;
public MovingObject(int initialVelocity, int duration, int acceleration) {
this.initialVelocity = initialVelocity;
this.duration = duration;
this.acceleration = acceleration;
}
@vincentius15
vincentius15 / oversampling.py
Created May 12, 2018 00:32
Image oversampling using Langrange Interpolation
from PIL import Image
def langrangeInterpolation(x,x0,x1,x2,x3,fx0,fx1,fx2,fx3):
fx = ((((x-x1)*(x-x2)*(x-x3))/((x0-x1)*(x0-x2)*(x0-x3))) *fx0) + ((((x-x0)*(x-x2)*(x-x3))/((x1-x0)*(x1-x2)*(x1-x3))) *fx1) + ((((x-x1)*(x-x0)*(x-x3))/((x2-x1)*(x2-x0)*(x2-x3))) *fx2) + ((((x-x1)*(x-x2)*(x-x0))/((x3-x1)*(x3-x2)*(x3-x0))) *fx3)
return fx
def resize(img):
pixels = img.load()
@vincentius15
vincentius15 / morphology.py
Created April 22, 2018 13:42
Morphology Image Processing
from PIL import Image
#thresholding
def thresholding(img):
#load image
pixels = img.load()
#create blank output image
output = Image.new(img.mode, img.size)
outputPixels = output.load()
@vincentius15
vincentius15 / huffman.cpp
Created February 20, 2018 11:38
File compressor using huffman code algorithm
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
typedef struct tree{
int count;