Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

went crazy. worked in too high a granularity cycle with not enough te…

…sting. Spent hours trying to add pixel and color space support.
  • Loading branch information...
commit 94f93ee1c95aa89e67738b514af74472c1ff29ef 1 parent cebaa6e
@leadVisionary authored
View
25 src/com/visionarysoftwaresolutions/camera/BasicCamera.java
@@ -1,25 +0,0 @@
-package com.visionarysoftwaresolutions.camera;
-
-import com.visionarysoftwaresolutions.camera.interfaces.Camera;
-import com.visionarysoftwaresolutions.camera.interfaces.Viewfinder;
-
-public class BasicCamera implements Camera {
- Viewfinder view;
-
- public BasicCamera(){
- setViewfinder(new BasicViewfinder(10,10));
- }
-
- public BasicCamera(Viewfinder v){
- setViewfinder(v);
- }
-
- private void setViewfinder(Viewfinder v) {
- view = v;
- }
-
- @Override
- public byte[] capture() {
- return view.getContents();
- }
-}
View
37 src/com/visionarysoftwaresolutions/camera/BasicDimension.java
@@ -1,37 +0,0 @@
-package com.visionarysoftwaresolutions.camera;
-
-import com.visionarysoftwaresolutions.camera.interfaces.Dimension;
-
-public class BasicDimension implements Dimension {
- private int width = 0;
- private int height = 0;
-
- public BasicDimension(int width, int height){
- setWidth(width);
- setHeight(height);
- }
-
- private void setWidth(int width){
- if(width < 0){
- throw new UnsupportedOperationException("Width cannot be less than 0");
- }
- this.width = width;
- }
-
- private void setHeight(int height){
- if(height < 0){
- throw new UnsupportedOperationException("Height cannot be less than 0");
- }
- this.height = height;
- }
-
- @Override
- public int getWidth() {
- return width;
- }
-
- @Override
- public int getHeight() {
- return height;
- }
-}
View
42 src/com/visionarysoftwaresolutions/camera/BasicViewfinder.java
@@ -1,42 +0,0 @@
-package com.visionarysoftwaresolutions.camera;
-
-import com.visionarysoftwaresolutions.camera.interfaces.Dimension;
-import com.visionarysoftwaresolutions.camera.interfaces.Viewfinder;
-
-public class BasicViewfinder implements Viewfinder {
- private Dimension dimensions;
-
- public BasicViewfinder(Dimension size){
- setDimensions(size);
- }
-
- public BasicViewfinder(int width, int height){
- setDimensions(new BasicDimension(width, height));
- }
-
- public void setDimensions(Dimension dim){
- this.dimensions = dim;
- }
-
- @Override
- public Dimension getDimensions() {
- return this.dimensions;
- }
-
- @Override
- public byte[] getContents() {
- byte[] results = new byte[dimensions.getWidth()*dimensions.getHeight()];
- for(int i = 0; i < dimensions.getWidth(); i++){
- for(int j = 0; j < dimensions.getHeight(); j++){
- results = collect();
- }
- }
- return results;
- }
-
- // TODO Could be abstract and subclassed to make BasicViewFinder a Template Method.
- // This part would do Native I/O interface
- private byte[] collect() {
- return new byte[dimensions.getWidth()*dimensions.getHeight()] ;
- }
-}
View
9 src/com/visionarysoftwaresolutions/camera/CameraDecorator.java
@@ -1,16 +1,17 @@
package com.visionarysoftwaresolutions.camera;
-import com.visionarysoftwaresolutions.camera.interfaces.Camera;
+import com.visionarysoftwaresolutions.camera.api.Camera;
+import com.visionarysoftwaresolutions.camera.api.Picture;
-public class CameraDecorator implements Camera {
+public abstract class CameraDecorator implements Camera {
private Camera camera;
- public CameraDecorator(Camera cam){
+ protected CameraDecorator(Camera cam){
camera = cam;
}
@Override
- public byte[] capture() {
+ public Picture capture() {
return camera.capture();
}
}
View
11 src/com/visionarysoftwaresolutions/camera/CameraFactory.java
@@ -1,11 +0,0 @@
-package com.visionarysoftwaresolutions.camera;
-
-import com.visionarysoftwaresolutions.camera.interfaces.Camera;
-
-public class CameraFactory {
-
- public static Camera create() {
- return new BasicCamera();
- }
-
-}
View
5 src/com/visionarysoftwaresolutions/camera/interfaces/Camera.java
@@ -1,5 +0,0 @@
-package com.visionarysoftwaresolutions.camera.interfaces;
-
-public interface Camera {
- public abstract byte[] capture();
-}
View
6 src/com/visionarysoftwaresolutions/camera/interfaces/Dimension.java
@@ -1,6 +0,0 @@
-package com.visionarysoftwaresolutions.camera.interfaces;
-
-public interface Dimension {
- public int getWidth();
- public int getHeight();
-}
View
6 src/com/visionarysoftwaresolutions/camera/interfaces/Viewfinder.java
@@ -1,6 +0,0 @@
-package com.visionarysoftwaresolutions.camera.interfaces;
-
-public interface Viewfinder {
- public abstract Dimension getDimensions();
- public abstract byte[] getContents();
-}
View
17 test/com/visionarysoftwaresolutions/camera/CameraTests.java
@@ -1,17 +0,0 @@
-package com.visionarysoftwaresolutions.camera;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-import com.visionarysoftwaresolutions.camera.interfaces.Camera;
-
-public class CameraTests {
-
- @Test
- public void testCaptureAPicture() {
- Camera toTest = CameraFactory.create();
- byte[] result = toTest.capture();
- assertNotNull(result);
- }
-}
View
17 test/com/visionarysoftwaresolutions/camera/DimensionTests.java
@@ -1,17 +0,0 @@
-package com.visionarysoftwaresolutions.camera;
-
-import org.junit.Test;
-
-public class DimensionTests {
-
- @Test(expected=UnsupportedOperationException.class)
- public void testNegativeWidth() {
- new BasicDimension(-10, 400);
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testNegativeHeight() {
- new BasicDimension(400, -10);
- }
-
-}
Please sign in to comment.
Something went wrong with that request. Please try again.