Commit 91d067e3 authored by stephanie.smith's avatar stephanie.smith

initial

parent 89aec285
No preview for this file type
No preview for this file type
No preview for this file type
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 getHeight(){return height;}
public int getWidth(){return width;}
public void setHeight(int height){this.height=height;}
public void setWidth(int width){this.width=width;}
public int getSize(){return size;}
public void setSize(int size){this.size=size;}
@Override
public float area() {
float area = getWidth() * getHeight();
return area;
}
@Override
public float circumference() {
float circ = getHeight() + getHeight() + getWidth() + getWidth();
return circ;
}
@Override
public void draw() {
}
}
abstract public class Shape {
protected int size;
int width;
int height;
abstract public void draw();
abstract public float area();
abstract public float circumference();
public int getHeight(){return height;}
public int getWidth(){return width;}
public int getSize() { return size; }
public void setSize(int size) { this.size = size; }
......
public class Square extends Shape{
public Square() {
super();
}
public Square(int i) {
super(i);
}
@Override
public float area() {
float fSize = size;
float area = fSize * fSize;
return area;
}
@Override
public float circumference() {
float fSize = size;
float circ = fSize *4;
return circ;
}
@Override
public void draw() {
}
}
......@@ -96,7 +96,7 @@ public class unitTest {
@Test
public void testRectangleWidth() {
// test setSize()
Shape testShape = new Rectangle(5,4);
Rectangle testShape = new Rectangle(5,4);
testShape.setWidth(6);
assertEquals(6, testShape.getWidth());
}
......@@ -104,7 +104,7 @@ public class unitTest {
@Test
public void testRectangleHeight() {
// test setSize()
Shape testShape = new Rectangle(78);
Rectangle testShape = new Rectangle(7,8);
testShape.setHeight(3);
assertEquals(3, testShape.getHeight());
}
......@@ -112,13 +112,13 @@ public class unitTest {
@Test
public void testRectangleCircumference() {
// test circumference()
Shape testShape = new Rectangle(6,3);
Rectangle testShape = new Rectangle(6,3);
assertEquals(18.0, testShape.circumference(), 1e-6);
}
@Test
public void testRectangleArea() {
// test area()
Shape testShape = new Rectangle(5,7);
Rectangle testShape = new Rectangle(5,7);
assertEquals(35.0, testShape.area(), 1e-6);
}
......
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