Comp 152 Project 6:
Automated Tests: now an extra credit project
Due: Mon Dec 13th at 11:59pm
Summary:
This project will give you a chance to practice with automated tests.
Project:
- Create a Maven based project as we've done before.
- create a bsu.comp152 package.
- copy the Rectangle.java code provided here into that package
- create at tests file (using junit) in the test/java folder
- write 4 automated tests to test the doesHit function, including one
that shows the error in the code that I gave you.
- eg one test might be to test a rectangle against itself. another
might be to test one that is no where near etc.
- write a comment in the tests file (directly over the test that fails
on the code that I gave you explaining what was wrong
- fix the 'production code' that I gave you.
The java code you will be testing (remember it has error(s):
package bsu.comp152;
public class Rectangle {
public int upperLeftX;
public int upperLeftY;
public int lowerRightX;
public int lowerRightY;
public Rectangle(int uleftX, int uleftY, int lRightX, int lRightY){
upperLeftX = uleftX;
upperLeftY = uleftY;
lowerRightX = lRightX;
lowerRightY = lRightY;
}
/**
*
* @param other -another rectangle
* @return should return true if this rectangle overlaps/intersections with the other rectangle
*/
public boolean doesHit(Rectangle other){
if (this.upperLeftY > other.lowerRightY && other.upperLeftY > this.lowerRightY)
return false;
if (this.upperLeftX>other.lowerRightX || other.upperLeftX > this.lowerRightX)
return false;
return true;
}
}
This project will be worth about as much as the first project.
Extra requirements for the project
Comment your code.
Include comments at the top of your testclass
your name
Anything you didn't get done
Submission:
upload the entire project, including
all of the maven files needed to run on another machine to github and make
me a collaborator as before.