Difference between revisions of "Shape"

From CSE231 Wiki
Jump to navigation Jump to search
Line 57: Line 57:
 
===area()===
 
===area()===
 
{{Sequential|public double area()}}
 
{{Sequential|public double area()}}
 +
 +
<math>\pi * r ^ 2</math>
  
 
=Testing Your Solution=
 
=Testing Your Solution=
 
==Correctness==
 
==Correctness==
 
{{TestSuite|ShapeTestSuite|shape.warmup}}
 
{{TestSuite|ShapeTestSuite|shape.warmup}}

Revision as of 07:10, 21 January 2020

Motivation

Experience with utilizing fields and implementing interfaces.

Mistakes To Avoid

Attention niels epting.svg Warning: Do NOT Parallelize

Code to Investigate

Shape

package shape.core;

public interface Shape {
	double area();
}


Code to Implement

Rectangle

public class Rectangle implements Shape
class: Rectangle.java Java.png
methods: constructor
area()
getX()
getY()
getWidth()
getHeight()
area()
package: shape.warmup
source folder: student/src/main/java

constructor

method: public Rectangle(double x, double y, double width, double height) Sequential.svg (sequential implementation only)

getX()

method: public double getX() Sequential.svg (sequential implementation only)

getY()

method: public double getY() Sequential.svg (sequential implementation only)

getWidth()

method: public double getWidth() Sequential.svg (sequential implementation only)

getHeight()

method: public double getHeight() Sequential.svg (sequential implementation only)

area()

method: public double area() Sequential.svg (sequential implementation only)

Circle

public class Circle implements Shape
class: Circle.java Java.png
methods: constructor
area()
getX()
getY()
getRadius()
area()
package: shape.warmup
source folder: student/src/main/java

constructor

method: public Circle(double x, double y, double radius) Sequential.svg (sequential implementation only)

getX()

method: public double getX() Sequential.svg (sequential implementation only)

getY()

method: public double getY() Sequential.svg (sequential implementation only)

getRadius()

method: public double getRadius() Sequential.svg (sequential implementation only)

area()

method: public double area() Sequential.svg (sequential implementation only)

Testing Your Solution

Correctness

class: ShapeTestSuite.java Junit.png
package: shape.warmup
source folder: testing/src/test/java