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 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;
}
public class Main {
public static void main(String[] args) {
MovingObject object = new MovingObject(10, 10, 10 );
System.out.println(object.displacement());
}
}
@vincentius15
vincentius15 / Client.py
Last active June 3, 2018 15:48
Chat Protocol
import socket
import select
import sys
from threading import *
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address = ("localhost", 14000)
client.connect(server_address)
@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()