This file contains hidden or 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
public interface Shape{ | |
double area(); | |
} | |
public class Square { | |
private int topLeftCoordinateX; | |
private int topLeftCoordinateY; | |
private int side; | |
public double area(){ |
This file contains hidden or 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
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; |
This file contains hidden or 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 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); | |
} |
This file contains hidden or 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
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()); | |
} | |
} |
This file contains hidden or 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
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; |
This file contains hidden or 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
public class Main { | |
public static void main(String[] args) { | |
MovingObject object = new MovingObject(10, 10, 10 ); | |
System.out.println(object.displacement()); | |
} | |
} |
This file contains hidden or 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
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; | |
} |
This file contains hidden or 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
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() |
This file contains hidden or 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
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() |
This file contains hidden or 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<stdio.h> | |
#include<stdlib.h> | |
#include<string.h> | |
#include<algorithm> | |
#include<math.h> | |
using namespace std; | |
typedef struct tree{ | |
int count; |
NewerOlder