Commit c5242f26 authored by daniel pearson's avatar daniel pearson

Origin

parent 89aec285
No preview for this file type
public class Rectangle extends Shape {
int width;
int height;
public Rectangle() {
width = 3;
height = 4;
}
public Rectangle(int width, int height) {
this.width = width;
this.height = height;
}
public int getWidth() {return width;}
public int getHeight() {return height;}
public void setWidth(int width) {this.width = width;}
public void setHeight(int height) {this.height = height;}
@Override
public void draw() {
// TODO Auto-generated method stub
}
@Override
public float area() {
return getWidth() * getHeight();
}
@Override
public float circumference() {
return getWidth() + getWidth() + getHeight() + getHeight();
}
}
public class Square extends Shape {
public Square() {
super();
}
public Square(int i) {
super(i);
}
@Override
public void draw() {
// TODO Auto-generated method stub
}
@Override
public float area() {
return size * size;
}
@Override
public float circumference() {
return size * 4;
}
}
...@@ -41,4 +41,6 @@ public class Triangle extends Shape{ ...@@ -41,4 +41,6 @@ public class Triangle extends Shape{
return circ; return circ;
} }
} }
...@@ -83,7 +83,7 @@ public class unitTest { ...@@ -83,7 +83,7 @@ public class unitTest {
@Test @Test
public void testRectangleConstructor() { public void testRectangleConstructor() {
// test default constructor // test default constructor
Shape testShape = new Rectangle(); Rectangle testShape = new Rectangle();
assertEquals(3, testShape.getWidth()); assertEquals(3, testShape.getWidth());
assertEquals(4, testShape.getHeight()); assertEquals(4, testShape.getHeight());
...@@ -96,7 +96,7 @@ public class unitTest { ...@@ -96,7 +96,7 @@ public class unitTest {
@Test @Test
public void testRectangleWidth() { public void testRectangleWidth() {
// test setSize() // test setSize()
Shape testShape = new Rectangle(5,4); Rectangle testShape = new Rectangle(5,4);
testShape.setWidth(6); testShape.setWidth(6);
assertEquals(6, testShape.getWidth()); assertEquals(6, testShape.getWidth());
} }
...@@ -104,7 +104,7 @@ public class unitTest { ...@@ -104,7 +104,7 @@ public class unitTest {
@Test @Test
public void testRectangleHeight() { public void testRectangleHeight() {
// test setSize() // test setSize()
Shape testShape = new Rectangle(78); Rectangle testShape = new Rectangle(7,8);
testShape.setHeight(3); testShape.setHeight(3);
assertEquals(3, testShape.getHeight()); assertEquals(3, testShape.getHeight());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment